@adobe/data - v0.10.30
    Preparing search index...

    Interface ConcurrencyStrategy

    The interface every concurrency strategy must satisfy.

    A strategy encapsulates all decisions about how locally-initiated transactions are applied and how inbound envelopes (from a sync service or another local source) are reconciled against the current store state.

    Two built-in strategies are provided:

    • createImmediateConcurrency() — commits apply immediately, no rollback queue. Use this as the base database for external wrappers (e.g. a collaborative-editing layer that manages its own replay buffer).

    • createRebaseReplayConcurrency(userId) — commits apply locally as intermediate steps and wait for the sync server's echoed committed envelope to promote them. Full rollback-and-replay queue, cross-peer id-determinism.

    interface ConcurrencyStrategy {
        apply: (
            envelope: TransactionEnvelope,
        ) => undefined | TransactionResult<unknown>;
        cancel: (id: number, userId?: string | number) => void;
        deferredCommit: boolean;
        onAfterFromData?: () => void;
        onAfterToData?: () => void;
        onBeforeToData?: () => void;
        onReset: () => void;
        userId?: string | number;
    }
    Index

    Properties

    apply: (envelope: TransactionEnvelope) => undefined | TransactionResult<unknown>

    Process a transaction envelope. Called by the dispatcher for each locally-initiated transaction and by sync services for inbound commits. Does NOT fire observe.envelopes (that is the dispatcher's job).

    cancel: (id: number, userId?: string | number) => void

    Cancel a pending intermediate step by compound (userId, id) key. No-op for strategies that have no intermediate queue.

    deferredCommit: boolean

    When true, the dispatcher applies "commit" intents as intermediate steps (negative time) and waits for a server echo to promote them. When false, commits apply immediately with positive time.

    onAfterFromData?: () => void

    Called immediately after db.fromData() loads a snapshot into the store. Strategies with an intermediate queue should replay pending intermediate steps here so in-progress work is visible after a data load.

    onAfterToData?: () => void

    Called immediately after db.toData() serializes the store. Strategies that roll back in onBeforeToData should replay here to restore the in-progress intermediate state.

    onBeforeToData?: () => void

    Called immediately before db.toData() serializes the store. Strategies with an intermediate queue should roll back intermediate steps here so the snapshot contains only committed state.

    When this hook (together with onAfterToData) is present, db.toData() serializes a detached copy of the store between the two hooks, so the onAfterToData replay cannot corrupt the returned snapshot. See Database.toData().

    onReset: () => void

    Called by db.reset() before the store is cleared. Strategies with an intermediate queue should clear it here.

    userId?: string | number

    Peer/session identifier stamped on every outbound envelope. Required for strategies that participate in a multi-peer sync protocol.