12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as t}from"../chunks/tslib.es6.js";import e from"./Accessor.js";import s from"./Logger.js";import{runTracked as a}from"./accessorSupport/tracking.js";import{property as n}from"./accessorSupport/decorators/property.js";import{subclass as r}from"./accessorSupport/decorators/subclass.js";import{SimpleTrackingTarget as o}from"./accessorSupport/tracking/SimpleTrackingTarget.js";const i=e=>{let a=class extends e{constructor(){super(...arguments),this._numUpdating=0,this.asyncUpdateState=new Map}get updating(){return this._numUpdating>0}autoUpdateAsync(t,e){return p((e=>this._updateAsync(t,e)),e)}async _updateAsync(t,e){if(!this._startAsyncUpdate(t)){try{const s=await e();this._set(t,s)}catch(a){s.getLogger(this.declaredClass).warn(`Async update of "${String(t)}" failed. Async update functions should not throw exceptions.`)}this._endAsyncUpdate(t)&&this._updateAsync(t,e)}}_startAsyncUpdate(t){const e=this.asyncUpdateState.get(t)??c.None;return e&c.Updating?(this.asyncUpdateState.set(t,e|c.Invalidated),!0):(++this._numUpdating,this.asyncUpdateState.set(t,e|c.Updating),!1)}_endAsyncUpdate(t){--this._numUpdating;const e=(this.asyncUpdateState.get(t)??c.None)&~c.Updating;return e&c.Invalidated?(this.asyncUpdateState.set(t,e&~c.Invalidated),!0):(this.asyncUpdateState.set(t,e),!1)}};return t([n({readOnly:!0})],a.prototype,"updating",null),t([n()],a.prototype,"_numUpdating",void 0),a=t([r("esri.core.AsyncUpdate")],a),a};var c;function p(t,e){const s=()=>{i&&!c&&t(n)},n=()=>{if(!i||c)return e();i.clear(),c=!0;const t=a(i,e);return c=!1,t},r=()=>{i&&(i.destroy(),i=null)};let i=new o(s),c=!1;return t(n),{remove:r}}!function(t){t[t.None=0]="None",t[t.Updating=1]="Updating",t[t.Invalidated=2]="Invalidated"}(c||(c={}));let d=class extends(i(e)){};d=t([r("esri.core.AsyncUpdate")],d);export{d as AsyncUpdate,i as AsyncUpdateMixin};
|