import Handles from "@arcgis/core/core/Handles.js";
Since
ArcGIS Maps SDK for JavaScript 4.7

This class helps manage a group of handles.

Constructors

Constructor

Constructor

Methods

MethodSignatureClass
add
add(handles: (H | null | undefined) | (H | null | undefined)[] | Collection<H | null | undefined>, groupKey?: T): this
destroy(): void
has
has(groupKey?: T): boolean
remove(groupKey?: T | T[] | Collection<T>): this
removeAll(): this

add

Method
Signature
add (handles: (H | null | undefined) | (H | null | undefined)[] | Collection<H | null | undefined>, groupKey?: T): this

Adds a group of handles.

Parameters

ParameterTypeDescriptionRequired
handles
(H | null | undefined) | (H | null | undefined)[] | Collection<H | null | undefined>

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 group
handles.add([handle1, handle2]); // added to the default group
handles.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

ParameterTypeDescriptionRequired
groupKey
T

group handle key

Returns
boolean

remove

Method
Signature
remove (groupKey?: T | T[] | Collection<T>): this

Removes a group of handles.

Parameters

ParameterTypeDescriptionRequired
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 group
handles.remove("handle-group");
handles.remove("other-handle-group");

removeAll

Method
Signature
removeAll (): this

Removes all handles.

Returns
this

Type definitions

ResourceHandle

Type definition

Represents a watch or event handler which can be removed.

remove

Method
Signature
remove (): void

Removes the handle.

Returns
void
Example
let handle = reactiveUtils.watch(() => map.basemap, (newVal) => {
// Each time the value of map.basemap changes, it is logged in the console
console.log("new basemap: ", newVal);
});
// When remove() is called on the watch handle, the map no longer watches for changes to basemap
handle.remove();