mobx-keystone
    Preparing search index...

    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.

    Index

    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]

        Object type.

      • R = void

        Return type.

      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.