Skip to main content
Module

x/automerge/next.ts>receiveSyncMessage

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
Go to Latest
function receiveSyncMessage
import { receiveSyncMessage } from "https://deno.land/x/automerge@2.2.0/next.ts";

Update a document and our sync state on receiving a sync message

Parameters

doc: Doc<T>
  • The doc the sync message is about
inState: SyncState
  • The SyncState for the peer we are communicating with
message: SyncMessage
  • The message which was received
optional
opts: ApplyOptions<T>
  • Any ApplyOptions, used for passing a PatchCallback which will be informed of any changes in doc which occur because of the received sync message.

Returns

[Doc<T>, SyncState, null]

An array of [newDoc, newSyncState, syncMessage | null] where newDoc is the updated state of doc, newSyncState should replace inState and syncMessage should be sent to the peer if it is not null. If syncMessage is null then we are up to date.