Libraries
    Preparing search index...

    Type Alias SubscriptionHandler<E>

    SubscriptionHandler: HasKeys<SubscriptionServiceSchemas<E>> extends true
        ? (
            arg: SubscriptionContext<E>,
            services: Simplify<InferServices<SubscriptionServiceSchemas<E>>>,
        ) => AsyncGenerator<OutgoingType<E>>
        : (arg: SubscriptionContext<E>) => AsyncGenerator<OutgoingType<E>>

    The handler function type inferred from a SubscriptionBuilder.

    Must be an async generator that yields outgoing events. When the endpoint has injected services, the handler receives a second services argument.

    Type Parameters

    • E
    const handler: SubscriptionHandler<typeof chatEndpoint> =
    async function* ({ incoming, principal }) {
    yield tracked('welcome', { text: 'Hello!' });
    for await (const msg of incoming) {
    yield { text: `${principal.name}: ${msg.text}` };
    }
    };