import Handles from "@arcgis/core/core/Handles.js";const Handles = await $arcgis.import("@arcgis/core/core/Handles.js");- Since
- ArcGIS Maps SDK for JavaScript 4.7
This class helps manage a group of handles.
Constructors
Methods
add
Method
- Signature
-
add (handles: (H | null | undefined) | (H | null | undefined)[] | Collection<H | null | undefined>, groupKey?: T): this
Adds a group of handles.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| handles | An array or collection handles to group. | | |
| groupKey | T | Key identifying the group to which the handles should be added. All the handles in the group can later be removed with remove(). If no key is provided the handles are added to a default group. | |
- Returns
- this
- Examples
- let handles = new Handles();handles.add(handle); // added to the default grouphandles.add([handle1, handle2]); // added to the default grouphandles.add(handle, "handle-group");handles.add([handle1, handle2], "other-handle-group");let handles = new Handles();handles.add(reactiveUtils.when(() => !view.updating,() => {wkidSelect.disabled = false;},{ once: true }));
destroy
Method
- Signature
-
destroy (): void
Destroys the object, removing all the handles.
- Returns
- void
- Example
- let handles = new Handles();handles.add(reactiveUtils.when(() => !view.updating,() => {wkidSelect.disabled = false;},{ once: true }));handles.destroy();
has
Method
- Signature
-
has (groupKey?: T): boolean
Returns true if a group exists for the provided group key, false otherwise.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| groupKey | T | group handle key | |
- Returns
- boolean
remove
Method
- Signature
-
remove (groupKey?: T | T[] | Collection<T>): this
Removes a group of handles.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| groupKey | T | T[] | Collection | A group key or an array or collection of group keys to remove. | |
- Returns
- this
- Example
- let handles = new Handles();handles.remove(); // removes handles from default grouphandles.remove("handle-group");handles.remove("other-handle-group");
Type definitions
ResourceHandle
Type definition
Represents a watch or event handler which can be removed.
- Example
- let handle = reactiveUtils.watch(() => map.basemap, (newVal) => {// Each time the value of map.basemap changes, it is logged in the consoleconsole.log("new basemap: ", newVal);});// When remove() is called on the watch handle, the map no longer watches for changes to basemaphandle.remove();