Metreeca Gear
    Preparing search index...

    Function service

    • Resolves a service.

      Returns the instance produced by the implementation bound to service in the enclosing execution, or by service itself if unbound, constructing it on first lookup and sharing it with every later lookup in the same execution.

      Warning

      A job must await the work it starts. A promise chain left unawaited keeps the execution around it, so a lookup in one of its continuations resolves after disposal has run, into an instance nothing will dispose.

      Type Parameters

      • T extends {} | null

        The type of the resolved service

      Parameters

      • service: Service<T>

        The service to be resolved

      Returns T

      The service instance for the enclosing execution

      If called outside an execution, reporting service; disposal of the execution's own services counts as outside, as does a callback invoked from work that escaped the execution, such as a timer

      If the service depends on itself, either directly or through other services, reporting the dependency chain