UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.43 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 o from"./Collection.js";import{sync as e}from"./reactiveUtils.js";import{property as s}from"./accessorSupport/decorators/property.js";import{subclass as r}from"./accessorSupport/decorators/subclass.js";import{autorun as i}from"./accessorSupport/trackingUtils.js";let l=class extends o{constructor(t){super(t),this.getCollections=null}initialize(){this.addHandles(i((()=>this._refresh()),e))}destroy(){this.getCollections=null}_refresh(){const t=null!=this.getCollections?this.getCollections():null;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 s of o)if(s){if(e(s)){const o=this.indexOf(s,t);o>=0?o!==t&&this.reorder(s,t):this.add(s,t),++t}if(this.getChildrenFunction){const o=this.getChildrenFunction(s);if(Array.isArray(o))for(const e of o)t=this._processCollection(t,e);else t=this._processCollection(t,o)}}return t}};t([s()],l.prototype,"getCollections",void 0),t([s()],l.prototype,"getChildrenFunction",void 0),t([s()],l.prototype,"itemFilterFunction",void 0),l=t([r("esri.core.CollectionFlattener")],l);export{l as default};