Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IObjectPool<T>

A pool of objects whose disposable lifecycle is tracked.

Type parameters

  • T: IObservableDisposable

    The type of object held in the pool.

Hierarchy

  • IDisposable
    • IObjectPool

Implemented by

Index

Properties

Readonly added

added: ISignal<this, T>

A signal emitted when an object is added.

This signal does not emit if an object is added using inject().

Readonly current

current: T | null

The current object.

Readonly currentChanged

currentChanged: ISignal<this, T | null>

A signal emitted when the current object changes.

Notes

If the last object being tracked is disposed, null will be emitted.

Readonly isDisposed

isDisposed: boolean

Test whether the object has been disposed.

Notes

This property is always safe to access.

Readonly size

size: number

The number of objects held by the pool.

Readonly updated

updated: ISignal<this, T>

A signal emitted when an object is updated.

Methods

dispose

  • dispose(): void
  • Dispose of the resources held by the object.

    Notes

    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    Undefined Behavior

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    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

Generated using TypeDoc