UNPKG

@arcgis/map-components

Version:
103 lines (102 loc) 3.14 kB
import { IHandle, Nil } from '@arcgis/components-utils'; export declare class Handles<T = string, H extends IHandle = IHandle> { /** * A handle to a {@link module:esri/views/layers/FeatureLayerView#highlight highlight} call result. * The handle can be used to remove the installed highlight. * * @typedef module:esri/core/Handles~Handle * * @property {Function} remove - Removes the handle. */ /** * Destroys the object, removing all the handles. * * @method destroy * @instance * * @example * let handles = new Handles(); * * handles.add(reactiveUtils.when( * () => !view.updating, * () => { * wkidSelect.disabled = false; * }, * { once: true } * )); * * handles.destroy(); */ destroy(): void; private _groups; /** * Adds a group of handles. * * @method add * @param {module:esri/core/Accessor~WatchHandle | module:esri/core/Accessor~WatchHandle[] | module:esri/core/Collection<module:esri/core/Accessor~WatchHandle>} handles - An array or collection handles to group. * @param {*} [groupKey] * Key identifying the group to which the handles should be added. All the handles in the group * can later be removed with {@link module:esri/core/Handles#remove Handles.remove()}. If no * key is provided the handles are added to a default group. * * @example * let handles = new Handles(); * * handles.add(handle); // added to the default group * handles.add([handle1, handle2]); // added to the default group * * handles.add(handle, "handle-group"); * handles.add([handle1, handle2], "other-handle-group"); * @example * let handles = new Handles(); * * handles.add(reactiveUtils.when( * () => !view.updating, * () => { * wkidSelect.disabled = false; * }, * { once: true } * )); * @instance */ add(handles: (H | Nil)[] | H | Nil, groupKey?: T): this; forEach(groupKey: T, callback: (handle: H) => void): void; forEach(callback: (handle: H) => void): void; /** * Returns true if a group exists for the provided group key, false otherwise. * * @method has * @instance * @param {*} groupKey - group handle key * @return {boolean} */ has(groupKey?: T): boolean; /** * Removes a group of handles. * * @method remove * @instance * @param {*} [groupKey] - A group key or an array or collection of group keys to remove. * * @example * let handles = new Handles(); * * handles.remove(); // removes handles from default group * * handles.remove("handle-group"); * handles.remove("other-handle-group"); */ remove(groupKey?: T | T[]): this; /** * Removes all handles. * * @method removeAll * @instance */ removeAll(): this; private _isHandle; private _getOrCreateGroup; private _getGroup; private _ensureGroupKey; private _removeAllFromGroup; }