DWS Packages
    Preparing search index...

    Global, type-safe store for named instances.

    Register an instance once at startup, then retrieve it anywhere by name without passing references around.

    Registry.register('db', new DatabaseConnection());
    const db = Registry.get<DatabaseConnection>('db');
    Index

    Constructors

    Methods

    • Removes every stored instance — useful for test teardown.

      Returns void

    • Retrieves the instance stored under name.

      The caller specifies the expected type via the generic parameter; no runtime type-check is performed.

      Type Parameters

      • TClass

        Expected type of the stored instance.

      Parameters

      • name: string

        Identifier of the instance to retrieve.

      Returns TClass

      (Exception) - name is not registered.

    • Checks whether an instance is stored under name.

      Parameters

      • name: string

        Identifier to look up.

      Returns boolean

    • Stores instance under the given name.

      Each name can only be registered once. Call unregister first if you need to replace an existing instance.

      Type Parameters

      • TClass extends object

        The type of the instance being stored.

      Parameters

      • name: string

        Unique identifier for this instance.

      • instance: TClass

        The object to store.

      Returns void

      (Exception) - name is already taken.

    • Removes the instance stored under name.

      After this call, name can be registered again with a new instance.

      Parameters

      • name: string

        Identifier of the instance to remove.

      Returns void

      (Exception) - name is not registered.