Vault is a small dependency injection container that works with Token. Internally it's implemented using a JavaScript object so that dependency lookups are fast and index based.

Hierarchy

  • Vault

Constructors

Properties

Methods

Constructors

Properties

container: {
    [key: Token]: Dependency;
} = {}

Type declaration

Methods

  • Performs a lookup for a dependency in the vault, using a token. Generically typed so clients don't need to perform type checks on the lookup result.

    Type Parameters

    • T extends unknown

    Parameters

    • token: Token

      the token that identifies the dependency.

    Returns undefined | T

    the dependency typed to T if it was found. If not found, the result is typed as undefined.

  • Stores a dependency in the vault, which is identified by a token.

    Parameters

    • value: {}

      the dependency to store. Typed to NonNullable so TypeScript can enforce non nullable/undefined dependencies.

      • token: Token

        the token that will allow lookups by an identifier.

      Returns void

    Generated using TypeDoc