Class RestorablePool<T>

An object pool that supports restoration.

Typeparam

T - The type of object being tracked.

Type Parameters

Implements

Constructors

Properties

_added: Signal<RestorablePool<T>, T> = ...
_current: null | T = null
_currentChanged: Signal<RestorablePool<T>, null | T> = ...
_hasRestored: boolean = false
_isDisposed: boolean = false
_objects: Set<T> = ...
_restore: null | IRestorable.IOptions<T> = null
_restored: PromiseDelegate<void> = ...
_updated: Signal<RestorablePool<T>, T> = ...
namespace: string

A namespace for all tracked objects.

Accessors

Methods

  • Add a new object to the pool.

    Parameters

    • obj: T

      The object object being added.

      Notes

      The object passed into the pool is added synchronously; its existence in the pool can be checked with the has() method. The promise this method returns resolves after the object has been added and saved to an underlying restoration connector, if one is available.

    Returns Promise<void>

  • Find the first object in the pool that satisfies a filter function.

    Parameters

    • fn: ((obj) => boolean)

      The filter function to call on each object.

        • (obj): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns undefined | T

  • Restore the objects in this pool's namespace.

    Parameters

    Returns Promise<any>

    A promise that resolves when restoration has completed.

    Notes

    This function should almost never be invoked by client code. Its primary use case is to be invoked by a layout restorer plugin that handles multiple restorable pools and, when ready, asks them each to restore their respective objects.