Sanity Library Reference Docs
    Preparing search index...

    Type Alias EventHandler<IData>

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

    A generic function handler that can receive the payload of any function type.

    The envelope is intentionally permissive so a single handler can be registered regardless of the event source without narrowing: context is any supported context, event is any supported event, and done is optional (present only for sync-tag-invalidate events).

    Type Parameters

    • IData = any

    Type declaration