7.0.5 • Published 1 year ago

@dcl/crdt v7.0.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

CRDT Protocol

Example

type Transport {
  send(message: Message): Promise<void>,
  on(evt: 'message' | 'error'): Promise<void>
}

const clientA = crdtProtocol<Buffer>(async (message: Message<Buffer>) => {
  await transportA.send(message)
}, uuid())

const clientB = crdtProtocol<Buffer>(async (message: Message<Buffer>) => {
  await transportB.send(message)
}, uuid())

transportA.on('message', clientA.processMessage)
transportB.on('message', clientB.processMessage)

const message = clientA.createEvent('keyA', Buffer.from('message'))
await clientA.sendMessage(message)
7.0.5

1 year ago