UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.7 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{handlesGroup as r,makeHandle as s}from"../../../core/handleUtils.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../core/accessorSupport/decorators.js";import a from"../../../rest/support/FeatureSet.js";import{isNumber as l}from"../../../support/guards.js";import{FeatureLikeLayerView2D as c}from"./FeatureLikeLayerView2D.js";import{handleNoEngineError as h}from"./support/handleNoEngineError.js";import u from"../../layers/StreamLayerView.js";let p=class extends(c(u)){constructor(){super(...arguments),this.pipelineConnectionStatus="disconnected",this.pipelineErrorString=null}initialize(){this.addHandles([n(()=>this.layer.customParameters,async e=>{(await this.getWorker()).streamMessenger.updateCustomParameters(e)}),this.layer.on("send-message-to-socket",async e=>{(await this.getWorker()).streamMessenger.sendMessageToSocket(e)}),this.layer.on("send-message-to-client",async e=>{(await this.getWorker()).streamMessenger.sendMessageToClient(e),this._isUserPaused&&"type"in e&&"clear"===e.type&&this.incrementSourceRefreshVersion()}),n(()=>this.layer.purgeOptions,()=>this._update()),n(()=>this.suspended,this._onSuspendedChange.bind(this))],"constructor"),this._doResume()}destroy(){this._doPause()}get connectionError(){return this.pipelineErrorString?new t("stream-controller",this.pipelineErrorString):null}on(e,t){if(Array.isArray(e))return r(e.map(e=>this.on(e,t)));const n=["data-received","message-received"].includes(e);n&&this.getWorker().then(t=>t.streamMessenger.enableEvent(e,!0));const i=super.on(e,t),o=this;return s(()=>{i.remove(),n&&(o._workerProxy.closed||o.hasEventListener(e)||o.getWorker().then(t=>t.streamMessenger.enableEvent(e,!1)))})}async queryLatestObservations(e,r){if(!(this.layer.timeInfo?.endField||this.layer.timeInfo?.startField||this.layer.timeInfo?.trackIdField))throw new t("streamlayer-no-timeField","queryLatestObservation can only be used with services that define a TrackIdField");const s=await this.getWorker();return h(s.features.executeQueryForLatestObservations(this._cleanUpQuery(e),r).then(e=>{const t=a.fromJSON(e);return t.features.forEach(e=>{e.layer=this.layer,e.sourceLayer=this.layer,e.origin=this.layer.graphicOrigin}),t}),new a({features:[]}))}detach(){super.detach(),this.pipelineConnectionStatus="disconnected"}onProxyClientEvent(e){this.emit(e.name,e.event)}async queryObjectIds(e,t){return(await super.queryObjectIds(e,t)).filter(l)}get _streamConnectionStatus(){return this.pipelineConnectionStatus}_doPause(){null!=this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=null)}_doResume(){null==this._refreshInterval&&(this._refreshInterval=setInterval(()=>this.incrementSourceRefreshVersion(),this.layer.updateInterval))}_doDisconnect(){this.getWorker().then(e=>e.streamMessenger.disconnect()),this._doPause()}_doConnect(){this.getWorker().then(e=>e.streamMessenger.connect()),this.resume()}_doClear(){this.getWorker().then(e=>e.streamMessenger.clear()),null==this._refreshInterval&&this.incrementSourceRefreshVersion()}_createClientOptions(){const e=super._createClientOptions(),t=this;return{...e,get container(){return t.featureContainer},setProperty:e=>{this.set(e.propertyName,e.value)}}}};e([i()],p.prototype,"pipelineConnectionStatus",void 0),e([i()],p.prototype,"pipelineErrorString",void 0),e([i({readOnly:!0})],p.prototype,"connectionError",null),e([i({readOnly:!0})],p.prototype,"_streamConnectionStatus",null),p=e([o("esri.views.2d.layers.StreamLayerView2D")],p);const d=p;export{d as default};