Sanity Library Reference Docs
    Preparing search index...

    Interface DocumentRemotePatchesEventBeta

    Event emitted when patches for a document are observed through the listener.

    Unlike the whole-document snapshots the store keeps, these are the raw patch operations from the transaction that produced the change, preserving the operational intent of the edit (e.g. keyed array inserts/unsets). Consumers that maintain their own local state, like collaborative text editors, can apply these directly instead of diffing document snapshots.

    origin is 'local' when the transaction was submitted by this document store instance (an own edit observed back through the listener) and 'remote' when it came from another client.

    interface DocumentRemotePatchesEvent {
        documentId: string;
        origin: "local" | "remote";
        patches: PatchOperations[];
        previousRev?: string;
        timestamp: string;
        transactionId: string;
        type: "remote-patches";
    }
    Index

    Properties

    documentId: string

    The ID of the document version the patches apply to (e.g. a draft ID).

    origin: "local" | "remote"

    Whether the transaction originated from this client or another one.

    patches: PatchOperations[]

    The patch operations, rooted at the document.

    previousRev?: string

    The revision the document was at before this transaction.

    timestamp: string

    The timestamp of the transaction.

    transactionId: string

    The transaction ID that carried these patches.

    type: "remote-patches"