RefreshableLayer.js 1.5 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Logger.js";import{debounce as s,ignoreAbortErrors as t}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{registerLayer as i,unregisterLayer as h}from"./refresh.js";function n(e){return null!=e&&"object"==typeof e&&"refreshTimestamp"in e&&"refresh"in e}const p=n=>{let p=class extends n{constructor(...e){super(...e),this.refreshInterval=0,this.refreshTimestamp=0,this._debounceHasDataChanged=s((()=>this.hasDataChanged())),this.when().then((()=>{i(this)}),(()=>{}))}destroy(){h(this)}get refreshParameters(){return{_ts:this.refreshTimestamp||null}}refresh(e=Date.now()){t(this._debounceHasDataChanged()).then((r=>{r&&this._set("refreshTimestamp",e),this.emit("refresh",{dataChanged:r})}),(e=>{r.getLogger(this.declaredClass).error(e),this.emit("refresh",{dataChanged:!1,error:e})}))}async hasDataChanged(){return!0}};return e([o({type:Number,cast:e=>e>=.1?e:e<=0?0:.1,json:{write:!0}})],p.prototype,"refreshInterval",void 0),e([o({readOnly:!0})],p.prototype,"refreshTimestamp",void 0),e([o()],p.prototype,"refreshParameters",null),p=e([a("esri.layers.mixins.RefreshableLayer")],p),p};export{p as RefreshableLayer,n as isRefreshableLayer};