Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RestorablePool<T>

An object pool that supports restoration.

Type parameters

  • T: IObservableDisposable = IObservableDisposable

    The type of object being tracked.

Hierarchy

  • RestorablePool

Implements

Index

Constructors

constructor

  • Create a new restorable pool.

    Type parameters

    • T: IObservableDisposable = IObservableDisposable

    Parameters

    • options: IOptions

      The instantiation options for a restorable pool.

    Returns RestorablePool

Properties

Private _added

_added: any

Private _current

_current: any

Private _currentChanged

_currentChanged: any

Private _hasRestored

_hasRestored: any

Private _isDisposed

_isDisposed: any

Private _objects

_objects: any

Private _onInstanceDisposed

_onInstanceDisposed: any

Clean up after disposed objects.

Private _restore

_restore: any

Private _restored

_restored: any

Private _updated

_updated: any

Readonly 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 | null): any
  • 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 | null

    Returns any

currentChanged

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

    Returns ISignal<this, T | null>

isDisposed

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

    Returns boolean

restored

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

    Returns Promise<void>

size

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

    Returns number

updated

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

    Returns ISignal<this, T>

Methods

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

  • 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: (obj: T) => boolean): T[]
  • Filter the objects in the pool based on a predicate.

    Parameters

    • fn: (obj: T) => boolean

      The function by which to filter.

        • (obj: T): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns T[]

find

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

    Parameters

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

          • obj: T

          Returns boolean

    Returns T | undefined

forEach

  • forEach(fn: (obj: T) => void): void
  • Iterate through each object in the pool.

    Parameters

    • fn: (obj: T) => void

      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