@intisy/bayonet
    Preparing search index...

    Interface ServiceRegistryShape

    One plugin's view of the live service registry, as reached through ContextSurface.

    want is two overloads rather than one method with an optional parameter, mirroring how assertManifest already renders an optional trailing argument for this same processor. watch's listener is a BiConsumer of the service and the event, so one subscription covers registration and withdrawal. get is | undefined because a missing service is an absent map entry rather than an answer.

    interface ServiceRegistryShape {
        get(id: string): unknown;
        ids(): string[];
        register(id: string, service: unknown): () => void;
        want(id: string): Promise<unknown>;
        want(id: string, options: WantOptionsShape): Promise<unknown>;
        watch(
            id: string,
            listener: (a: unknown, b: "register" | "unregister") => void,
        ): () => void;
    }
    Index
    • The service registered under an id right now, or undefined.

      Parameters

      • id: string

        the service id to look up

      Returns unknown

      the registered service, or undefined when none is registered

    • Every id registered right now.

      Returns string[]

      the registered service ids, or empty when none is registered

    • Registers a service. Call the result to withdraw it.

      Parameters

      • id: string

        the service id to register under

      • service: unknown

        the value other plugins reach through get, want or watch

      Returns () => void

      a disposer that withdraws the registration when called

    • Waits for a service to arrive, under the registry's default deadline.

      Parameters

      • id: string

        the service id to wait for

      Returns Promise<unknown>

      a promise that resolves with the service once registered, or rejects on timeout

    • Waits for a service to arrive, under the deadline given.

      Parameters

      • id: string

        the service id to wait for

      • options: WantOptionsShape

        the deadline to wait under

      Returns Promise<unknown>

      a promise that resolves with the service once registered, or rejects on timeout

    • Watches one id for registration and unregistration. Call the result to stop.

      Parameters

      • id: string

        the service id to watch

      • listener: (a: unknown, b: "register" | "unregister") => void

        called with the service and the event on each registration or unregistration

      Returns () => void

      a disposer that cancels the watch when called