UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.74 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 t}from"../../../chunks/tslib.es6.js";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}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{graphicCallback as n}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&&(n({type:"content",value:r,event:{graphic:e}}),this._set("created",null))}async _createContent(t){const e=this.graphic;if(!e||!t)return;const r=n({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([a("esri.widgets.Feature.FeatureContent.FeatureContentViewModel")],c);export{c as default};