Sanity Library Reference Docs
    Preparing search index...

    Type Alias PubSubEventHandler<IData, IResult>

    PubSubEventHandler: (
        envelope: {
            context: GenericContext;
            done?: SyncTagInvalidateCallback;
            event: DocumentEvent<IData> | SyncTagInvalidateEvent;
        },
    ) => IResult
    | Promise<IResult>

    A function handler for a pubsub event.

    A pubsub function can be triggered by any event source, so the envelope is intentionally permissive and needs no narrowing: context is any supported context, event is any supported event, and done is optional (present only for sync-tag-invalidate events).

    IResult is the value the handler resolves to and defaults to void. Pubsub is the one function type that may be invoked with invoke(name, payload, {sync: true}), which returns the handler's resolved value to the caller.

    Type Parameters

    • IData = any
    • IResult = void

    Type declaration