Yjs Protocols
Binary encoding protocols for syncing, awareness, and history inforamtion
This API is unstable and subject to change.
API
Awareness Protocoll
import * as awarenessProtocol from 'y-protocols/awareness.js'
awarenessProtocol.Awareness Class
The Awareness class implements a simple network agnostic protocol to propagate awareness information like cursor, username, or status. Each client can update its own local state and listen to state changes of remote clients.
const awareness = new awarenessProtocol.Awareness()
- Get the local awareness state.
- Set/Update the local awareness state. Set `null` to mark the local client as offline.
- Only update a single field on the local awareness object. Does not do anything if the local state is not set.
- Get all client awareness states (remote and local). Maps from clientID to awareness state.
- Listen to remote and local changes on the awareness instance.
getLocalState():Object<string,any>|null
setLocalState(Object<string,any>|null)
setLocalStateField(string, any)
getStates():Map<number,Object<string,any>>
on('change', ({ added: Array<number>, updated: Array<number> removed: Array<number> }, [transactionOrigin:any]) => ..)
License
The MIT License © Kevin Jahns