Function ywasm::__wasm_bindgen_generated_encodeStateVector[][src]

pub extern "C" fn __wasm_bindgen_generated_encodeStateVector(
    arg0: <YDoc as RefMutFromWasmAbi>::Abi
) -> <Uint8Array as ReturnWasmAbi>::Abi
Expand description

Encodes a state vector of a given ywasm document into its binary representation using lib0 v1 encoding. State vector is a compact representation of updates performed on a given document and can be used by encode_state_as_update on remote peer to generate a delta update payload to synchronize changes between peers.

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)