Hosanna UI API v1.30.2-next
    Preparing search index...

    InstancePool manages reusable object instances for performance and memory efficiency. Implements the IInstancePool interface.

    Implements

    Index

    Constructors

    Properties

    classDefaultsByClassName: Record<string, JsonData> = {}

    Class-default pendingState snapshot per pool key (same string as get / _cacheKey). Not stored on constructors — Roku function refs cannot hold expando properties.

    clazzMap: Record<string, new () => IReusable> = {}

    Maps class names to their constructors for instantiation.

    inUseByClassName: Record<string, Record<string, IReusable>> = {}

    In-use instances keyed by className then stable pool key (Record, not Set/Map).

    inUseKeySeq: number = 0

    Monotonic id for pool keys when _hid is absent.

    pool: Record<string, IReusable[]> = {}

    The pool of reusable instances, keyed by class name.

    usedInstances: Record<string, number> = {}

    Tracks the number of used instances for each class.

    Methods

    • Parameters

      • item: IReusable
      • className: string
      • poolKey: string

      Returns IPoolInstanceDebugInfo

    • On the very first construction for a pool key, snapshot the pendingState produced by @state / @layoutState field initialisers so that onWillReuse can restore a recycled instance to its class-default state. Captured once per class name.

      Parameters

      Returns void

    • Retrieves an instance of the specified class from the pool or creates a new one if none are available.

      Type Parameters

      • T extends IReusable

        The type of the reusable instance.

      Parameters

      • className: string

        The name of the class to retrieve an instance for.

      • Optionalclazz: new () => T

        The constructor of the class to instantiate if no instances are available in the pool.

      Returns T

      An instance of the specified class.

    • Snapshot of class-level

      Parameters

      • className: string

      Returns undefined | JsonData

      /

      initialisers for pooled reuse, keyed by pool class name. Stored on the pool (not on the constructor) so Roku builds work — function references there cannot carry expando properties.

    • Debug-only: instances classified as dangling (likely leak or inconsistent lifecycle).

      Returns IPoolInstanceDebugInfo[]

    • Debug-only: snapshot of in-use instances per class (plain objects, JSON-safe).

      Returns Record<string, IPoolInstanceDebugInfo[]>

    • Prepopulates the pool with a specified number of items.

      Type Parameters

      Parameters

      • className: string

        The class name to use as the key in the pool.

      • clazz: new () => T

        The class constructor to create new instances.

      • count: number

        The number of items to create and add to the pool.

      Returns void

    • Parameters

      Returns string

    • Releases an item back into the pool for reuse.

      Type Parameters

      • T extends IReusable

        The type of the item that extends IReusable.

      Parameters

      • item: T

        The item to be released back into the pool.

      Returns void

      If the pool for the item's class does not exist, it will be created. If the item has an onWillRelease method, it will be called before the item is added back to the pool.

    • Parameters

      Returns void