Skip to main content

Class: SandboxManager

Manager class returned by sandbox that allows you to make changes to a sandbox copy of the original subtree and apply them to the original subtree or reject them.

Constructors​

Constructor​

new SandboxManager(subtreeRoot): SandboxManager;

Creates an instance of SandboxManager. Do not use directly, use sandbox instead.

Parameters​

ParameterTypeDescription
subtreeRootobjectSubtree root target object.

Returns​

SandboxManager

Methods​

dispose()​

dispose(): void;

Disposes of the sandbox.

Returns​

void


withSandbox()​

withSandbox<T, R>(nodes, fn): R;

Executes fn with sandbox copies of the elements of nodes. The changes made to the sandbox in fn can be accepted, i.e. applied to the original subtree, or rejected.

Type Parameters​

Type ParameterDefault typeDescription
T extends readonly [object, object]-Object type.
RvoidReturn type.

Parameters​

ParameterTypeDescription
nodesTTuple of objects for which to obtain sandbox copies.
fnWithSandboxCallback<T, R>Function that is called with sandbox copies of the elements of nodes. Any changes made to the sandbox are applied to the original subtree when fn returns true or { commit: true, ... }. When fn returns false or { commit: false, ... } the changes made to the sandbox are rejected.

Returns​

R

Value of type R when fn returns an object of type { commit: boolean; return: R } or void when fn returns a boolean.