Interface Module<P>

A pre-defined set of resource providers and scopes that can be applied to any Container.

See

The Module function

Type Parameters

Hierarchy

  • BaseModule<P>
    • Module

Constructors

constructor

Methods

  • Given a FactoryKey or similar, return the result of the factory function after applying args.

    Type Parameters

    • K extends Of<((...args) => any), any, any>

      Type of the factory key

    • Th extends RequestFailed<unknown>

      A this-type bound enforcing that K is safe to request

    • Args extends unknown[]

      The factory's parameter list type

    • Out = Target<K, Merge<DefaultGraph, P>> extends ((...args) => O)
          ? O
          : unknown

      The factory's return type

    Parameters

    • this: Module<P> & Th
    • fac: K

      A FactoryKey or similar key that resolves to a function

    • Rest ...args: Args

    Returns Out

    See

    build

  • Given a FactoryKey or similar, asynchronously return the result of the factory function after applying args.

    It is safe to call method when some dependencies cannot be resolved synchronously.

    Type Parameters

    • K extends Of<((...args) => any), any, any>

      Type of the factory key

    • Th extends RequestFailed<unknown>

      A this-type bound enforcing that K is safe to request

    • Args extends unknown[]

      The factory's parameter list type

    • Out = Target<K, Merge<DefaultGraph, P>> extends ((...args) => O)
          ? O
          : unknown

      The factory's return type

    Parameters

    • this: Module<P> & Th
    • fac: K

      A FactoryKey or similar key that resolves to a possibly async function

    • Rest ...args: Args

    Returns Promise<Out>

  • Calls the given function with the requested dependencies and returns its output.

    Type Parameters

    • K extends DependencyKey

    • R

    • Th extends RequestFailed<unknown>

      A this-type bound enforcing that K is safe to request

    Parameters

    • this: Module<P> & Th
    • deps: K

      A key object specifying which dependencies to request

    • f: ((deps) => R)

      A function that accepts the dependencies specified by deps

    Returns R

    See

    inject

  • Asynchronously calls the given function with the requested dependencies and returns its output.

    It is safe to call method when some dependencies cannot be resolved synchronously.

    Type Parameters

    • K extends DependencyKey

    • R

    • Th extends RequestFailed<unknown>

      A this-type bound enforcing that K is safe to request

    Parameters

    • this: Module<P> & Th
    • deps: K

      A key object specifying which dependencies to request

    • f: ((deps) => R | Promise<R>)

      A possibly async function that accepts the dependencies specified by deps

        • (deps): R | Promise<R>
        • Parameters

          Returns R | Promise<R>

    Returns Promise<R>

    A promise resolving to the output of f

  • Requests the dependency specified by the given key, statically checking that the dependency is safe to request.

    Type Parameters

    Parameters

    • this: Module<P> & Th
    • deps: K

    Returns Target<K, Merge<DefaultGraph, P>>

    The requested dependency

    See

    request

  • Asynchronously requests the dependency specified by the given key, statically checking that the dependency is safe to request.

    It is safe to call method when some dependencies cannot be resolved synchronously.

    Type Parameters

    Parameters

    • this: Module<P> & Th
    • deps: K

    Returns Promise<Target<K, Merge<DefaultGraph, P>>>

    A promise resolving to the requested dependency

  • Asynchronously requests the dependency specified by the given key, without statically checking that the dependency is safe to request.

    Type Parameters

    Parameters

    • key: K

    Returns Promise<Target<K, Merge<DefaultGraph, P>>>

    A promise resolving to the requested dependency

  • Requests the dependency specified by the given key, without statically checking that the dependency is safe to request.

    Type Parameters

    Parameters

    • key: K

      A key specifying the dependency to request

    Returns Target<K, Merge<DefaultGraph, P>>

    The requested dependency

Generated using TypeDoc