Documentation
    Preparing search index...

    Class ComponentRegistry

    One-component-per-type storage with §6a lifecycle, in insertion order.

    Constructed with the host that components will see; a Node passes itself. When no host is supplied the registry acts as its own host, which keeps it usable standalone (and in tests).

    Implements

    Index
    • get components(): IterableIterator<Component>

      Live components in insertion order.

      Returns IterableIterator<Component>

    • get size(): number

      Number of attached components.

      Returns number

    • Registers component, replacing any existing component of the same typeName. The replaced component is detached (never disposed) and a development warning is emitted (§6a).

      Order: the new component is registered first, then onAttach runs, so a component that inspects host.getComponent(...) from onAttach sees itself. On replacement the old component's onDetach runs before the new component's onAttach.

      Type Parameters

      Parameters

      • component: T

      Returns T

    • Disposes every component in reverse insertion order (teardown mirrors construction, as in disposeAll), detaching each one first. The registry is empty afterwards.

      Returns void

    • Returns the attached component of type, or undefined.

      Type Parameters

      Parameters

      Returns T | undefined

    • True when a component of type is attached.

      Type Parameters

      Parameters

      Returns boolean

    • Removes component and runs its onDetach. Returns false when the component is not the one currently attached for its type. Detaching does not dispose (§6a).

      Parameters

      Returns boolean