UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.32 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import o from"./Collection.js";import{sync as e}from"./reactiveUtils.js";import{property as r}from"./accessorSupport/decorators/property.js";import{subclass as s}from"./accessorSupport/decorators/subclass.js";import{autorun as i}from"./accessorSupport/trackingUtils.js";let n=class extends o{constructor(t){super(t),this.getCollections=null}initialize(){this.addHandles(i(()=>this._refresh(),e))}destroy(){this.getCollections=null}_refresh(){const t=this.getCollections?.();if(null==t)return void this.removeAll();let o=0;for(const e of t)null!=e&&(o=this._processCollection(o,e));this.splice(o)}_createNewInstance(t){return new o(t)}_processCollection(t,o){if(!o)return t;const e=this.itemFilterFunction??(t=>!!t);for(const r of o)if(r){if(e(r)){const o=this.indexOf(r,t);o>=0?o!==t&&this.reorder(r,t):this.add(r,t),++t}if(this.getChildrenFunction){const o=this.getChildrenFunction(r);if(Array.isArray(o))for(const e of o)t=this._processCollection(t,e);else t=this._processCollection(t,o)}}return t}};t([r()],n.prototype,"getCollections",void 0),t([r()],n.prototype,"getChildrenFunction",void 0),t([r()],n.prototype,"itemFilterFunction",void 0),n=t([s("esri.core.CollectionFlattener")],n);const l=n;export{l as default};