Function ywasm::__wasm_bindgen_generated_encodeStateAsUpdate[][src]

pub extern "C" fn __wasm_bindgen_generated_encodeStateAsUpdate(
    arg0: <YDoc as RefMutFromWasmAbi>::Abi,
    arg1: <Option<Uint8Array> as FromWasmAbi>::Abi
) -> <Uint8Array as ReturnWasmAbi>::Abi
Expand description

Encodes all updates that have happened since a given version vector into a compact delta representation using lib0 v1 encoding. If vector parameter has not been provided, generated delta payload will contain all changes of a current ywasm document, working effectivelly as its state snapshot.

Example:

import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'

/// document on machine A
const localDoc = new YDoc()
const localSV = encodeStateVector(localDoc)

// document on machine B
const remoteDoc = new YDoc()
const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)

applyUpdate(localDoc, remoteDelta)