UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.46 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as i,subclass as n}from"../../../core/accessorSupport/decorators.js";import{graphicCallback as a}from"../support/featureUtils.js";let c=class extends r{constructor(t){super(t),this._loadingPromise=null,this.created=null,this.creator=null,this.destroyer=null,this.graphic=null,this.addHandles(o(()=>this.creator,t=>{this._destroyContent(),this._createContent(t)},s))}destroy(){this._destroyContent()}get state(){return this._loadingPromise?"loading":"ready"}_destroyContent(){const{created:t,graphic:e,destroyer:r}=this;t&&e&&(a({type:"content",value:r,event:{graphic:e}}),this._set("created",null))}async _createContent(t){const e=this.graphic;if(!e||!t)return;const r=a({type:"content",value:t,event:{graphic:e}});this._loadingPromise=r,this.notifyChange("state");const o=await r;r===this._loadingPromise&&(this._loadingPromise=null,this.notifyChange("state"),this._set("created",o))}};t([i({readOnly:!0})],c.prototype,"created",void 0),t([i()],c.prototype,"creator",void 0),t([i()],c.prototype,"destroyer",void 0),t([i({type:e})],c.prototype,"graphic",void 0),t([i({readOnly:!0})],c.prototype,"state",null),c=t([n("esri.widgets.Feature.FeatureContent.FeatureContentViewModel")],c);export{c as default};