Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RestorablePool<T>

An object pool that supports restoration. A namespace for RestorablePool statics.

Type parameters

  • T: IObservableDisposable

    The type of object being tracked.

Hierarchy

  • RestorablePool

Implements

Index

Constructors

constructor

Properties

Private _added

_added: Signal<this, T> = new Signal<this, T>(this)

Private _current

_current: T | null = null

Private _currentChanged

_currentChanged: Signal<this, T> = new Signal<this, T | null>(this)

Private _hasRestored

_hasRestored: boolean = false

Private _isDisposed

_isDisposed: boolean = false

Private _objects

_objects: Set<T> = new Set<T>()

Private _restore

_restore: IOptions<T> | null = null

Private _restored

_restored: PromiseDelegate<void> = new PromiseDelegate<void>()

Private _updated

_updated: Signal<this, T> = new Signal<this, T>(this)

namespace

namespace: string

A namespace for all tracked objects.

Accessors

added

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

current

  • get current(): T | null
  • set current(obj: T): void
  • 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 | null

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

    Parameters

    • obj: T

    Returns void

currentChanged

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

    Returns ISignal<this, T | null>

isDisposed

  • get isDisposed(): boolean

restored

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

    Returns Promise<void>

size

  • get size(): number

updated

  • get updated(): ISignal<this, T>

Methods

Private _onInstanceDisposed

  • _onInstanceDisposed(obj: T): void

add

  • add(obj: T): Promise<void>
  • Add a new object to the pool.

    Parameters

    • obj: T

      The object object being added.

      Notes

      The object passed into the tracker is added synchronously; its existence in the tracker 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

  • dispose(): 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

  • filter(fn: function): T[]
  • Filter the objects in the pool based on a predicate.

    Parameters

    • fn: function

      The function by which to filter.

        • (obj: T): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns T[]

find

  • find(fn: function): T | undefined
  • Find the first object in the pool that satisfies a filter function.

    Parameters

    • fn: function
        • (obj: T): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns T | undefined

forEach

  • forEach(fn: function): void
  • Iterate through each object in the pool.

    Parameters

    • fn: function

      The function to call on each object.

        • (obj: T): void
        • Parameters

          • obj: T

          Returns void

    Returns void

has

  • has(obj: T): boolean
  • Check if this pool has the specified object.

    Parameters

    • obj: T

      The object whose existence is being checked.

    Returns boolean

inject

  • inject(obj: T): Promise<void>
  • 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

  • restore(options: IOptions<T>): Promise<any>
  • Restore the objects in this pool's namespace.

    Parameters

    • options: IOptions<T>

      The configuration options that describe restoration.

    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

  • save(obj: T): Promise<void>
  • Save the restore data for a given object.

    Parameters

    • obj: T

      The object being saved.

    Returns Promise<void>

Generated using TypeDoc