zibri
    Preparing search index...

    Interface EventServiceInterface<TEvents>

    Interface for an event service.

    interface EventServiceInterface<TEvents extends Record<string, unknown>> {
        emit: <K extends string | number | symbol>(
            type: K,
            data: TEvents[K],
            cleanupAfterMs?: number,
        ) => void | Promise<void>;
        subscribe: <K extends string | number | symbol>(
            type: K,
            hook: (value: Event<TEvents[K]>) => void | Promise<void>,
            options: EventSubscribeOptions,
        ) => EventSubscriptionInterface | Promise<EventSubscriptionInterface>;
        subscribeAll: (
            hook: (value: Event<TEvents[keyof TEvents]>) => void | Promise<void>,
            options: EventSubscribeOptions,
        ) => EventSubscriptionInterface | Promise<EventSubscriptionInterface>;
    }

    Type Parameters

    • TEvents extends Record<string, unknown>

    Implemented by

    Index

    Properties

    emit: <K extends string | number | symbol>(
        type: K,
        data: TEvents[K],
        cleanupAfterMs?: number,
    ) => void | Promise<void>

    Emits an event of the given type and data.

    subscribe: <K extends string | number | symbol>(
        type: K,
        hook: (value: Event<TEvents[K]>) => void | Promise<void>,
        options: EventSubscribeOptions,
    ) => EventSubscriptionInterface | Promise<EventSubscriptionInterface>

    Subscribes to events of the given type with the given hook.

    Additional options can be provided, like eg. Retries or the id of the subscriber. This needs to be unique.

    subscribeAll: (
        hook: (value: Event<TEvents[keyof TEvents]>) => void | Promise<void>,
        options: EventSubscribeOptions,
    ) => EventSubscriptionInterface | Promise<EventSubscriptionInterface>

    Subscribes to ALL events with the given hook.

    Additional options can be provided, like eg. Retries or the id of the subscriber. This needs to be unique.