Skip to content

Type Editor


Type Editor / @type-editor/collab / receive-transaction / receiveTransaction

Function: receiveTransaction()

ts
function receiveTransaction(state, steps, clientIDs, options?): PmTransaction;

Defined in: receive-transaction.ts:29

Creates a transaction that represents a set of new steps received from the central authority. Applying this transaction moves the state forward to adjust to the authority's view of the document.

This function handles three scenarios:

  1. Steps that originated from this client are confirmed and removed from unconfirmed.
  2. Steps from other clients are applied directly if there are no local changes.
  3. If there are local unconfirmed changes, they are rebased over the remote steps.

Parameters

ParameterTypeDescription
statePmEditorStateThe current editor state.
stepsreadonly PmStep[]The steps received from the central authority.
clientIDsreadonly (string | number)[]The client IDs corresponding to each step, used to identify which steps originated from this client.
optionsReceiveTransactionOptionsOptional configuration for how to handle the transaction.

Returns

PmTransaction

A transaction that applies the received steps and updates the collab state.