Class RestorablePool<T>

An object pool that supports restoration.

Typeparam

T - The type of object being tracked.

Type Parameters

Hierarchy

  • RestorablePool

Implements

Constructors

Properties

_added: any
_current: any
_currentChanged: any
_hasRestored: any
_isDisposed: any
_objects: any
_onInstanceDisposed: any

Clean up after disposed objects.

_restore: any
_restored: any
_updated: any
namespace: string

A namespace for all tracked objects.

Accessors

  • get added(): ISignal<this, T>
  • A signal emitted when an object object is added.

    Notes

    This signal will only fire when an object is added to the pool. It will not fire if an object injected into the pool.

    Returns ISignal<this, T>

  • get current(): T
  • The current object.

    Notes

    The restorable pool does not set current. It is intended for client use.

    If current is set to an object that does not exist in the pool, it is a no-op.

    Returns T

  • set current(obj): void
  • The current object.

    Parameters

    • obj: T

    Returns void

  • get currentChanged(): ISignal<this, T>
  • A signal emitted when the current widget changes.

    Returns ISignal<this, T>

  • get isDisposed(): boolean
  • Test whether the pool is disposed.

    Returns boolean

  • get restored(): Promise<void>
  • A promise resolved when the restorable pool has been restored.

    Returns Promise<void>

  • get size(): number
  • The number of objects held by the pool.

    Returns number

  • get updated(): ISignal<this, T>
  • A signal emitted when an object is updated.

    Returns ISignal<this, T>

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>

  • Dispose of the resources held by the pool.

    Notes

    Disposing a pool does not affect the underlying data in the data connector, it simply disposes the client-side pool without making any connector calls.

    Returns void

  • Filter the objects in the pool based on a predicate.

    Parameters

    • fn: ((obj) => boolean)

      The function by which to filter.

        • (obj): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns T[]

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

    Parameters

    • fn: ((obj) => boolean)
        • (obj): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns T

  • Iterate through each object in the pool.

    Parameters

    • fn: ((obj) => void)

      The function to call on each object.

        • (obj): void
        • Parameters

          • obj: T

          Returns void

    Returns void

  • Check if this pool has the specified object.

    Parameters

    • obj: T

      The object whose existence is being checked.

    Returns boolean

  • Inject an object into the restorable pool without the pool handling its restoration lifecycle.

    Parameters

    • obj: T

      The object to inject into the pool.

    Returns Promise<void>

  • 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.

  • Save the restore data for a given object.

    Parameters

    • obj: T

      The object being saved.

    Returns Promise<void>

Generated using TypeDoc