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

Methods

Constructors

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

    Parameters

    • subtreeRoot: object

      Subtree root target object.

    Returns SandboxManager

Methods

  • Disposes of the sandbox.

    Returns void

  • 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

    • T extends readonly [object, object]
    • R = void

    Parameters

    • nodes: T

      Tuple of objects for which to obtain sandbox copies.

    • fn: WithSandboxCallback<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.

    Typeparam

    T Object type.

    Typeparam

    R Return type.