UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.89 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import"../../core/has.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{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{excludeTables as n}from"../../core/accessorSupport/layerContainerType.js";import{registerLayer as h,unregisterLayer as p}from"./refresh.js";function m(e){return null!=e&&"object"==typeof e&&"refreshTimestamp"in e&&"refresh"in e}const c=.1,f=m=>{let f=class extends m{constructor(...e){super(...e),this.refreshInterval=0,this.refreshTimestamp=0,this._debounceHasDataChanged=s((()=>this.hasDataChanged())),this.when().then((()=>{this.destroyed||h(this)}),(()=>{}))}destroy(){p(this)}castRefreshInterval(e){return e>=c?e:e<=0?0:c}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).error(e),this.emit("refresh",{dataChanged:!1,error:e})}))}async hasDataChanged(){return!0}get test(){}};return e([o({type:Number,json:{write:!0,origins:{"web-scene":{write:{enabled:!0,layerContainerTypes:n}}}}})],f.prototype,"refreshInterval",void 0),e([a("refreshInterval")],f.prototype,"castRefreshInterval",null),e([o({readOnly:!0})],f.prototype,"refreshTimestamp",void 0),e([o({readOnly:!0})],f.prototype,"refreshParameters",null),f=e([i("esri.layers.mixins.RefreshableLayer")],f),f};export{f as RefreshableLayer,m as isRefreshableLayer};