Metreeca Gear
    Preparing search index...

    Type Alias Service<T>

    Service: () => T

    Service factory.

    Constructs the instance backing a facility and identifies that facility across lookups and bindings.

    Doubling as the identity means services are looked up and bound by reference, so a service must be declared in a single module and re-exported by reference only, as wrapping it in a new function forks the identity and silently declares a second service.

    Construction must be synchronous and free of I/O, deferring such work to the instance's own methods. A service that throws must undo whatever it has already done, as a failed lookup records nothing and a later lookup runs it again.

    Releasing whatever the instance holds is opt-in: an instance exposing a callable Symbol.asyncDispose or Symbol.dispose member, either its own or inherited, is disposed as the execution ends, as detailed under Executor; any other instance is left as it is.

    Important

    Because the constructing function carries the identity, naming a service links its default implementation: the module declaring a service must stay import-light, requiring heavy clients lazily inside the default implementation rather than at module level.

    Type Parameters

    • T extends Defined

      The type of the constructed instance, undefined excepted, as it marks a service under construction

    Type Declaration

      • (): T
      • Returns T