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: a bound implementation is ready before the job is handed control, an unbound default is constructed on first lookup, and either way every later lookup in the same execution is handed the same instance.

      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

      Error 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

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

      Error If service is bound and looked up from a factory the execution is constructing before that binding is ready, unwinding the construction to be run again as detailed at Executor; a factory must let this error through unchanged rather than replacing or swallowing it