Class WebxdcProvider<I>

Source
Expand description

Webxdc integration with yjs.

The provider lets you manage state as yjs objects and have the provider propagate these state changes to other instances of the same app over the Webxdc network.

Constructors§

Source§

new WebxdcProvider<I extends Item = UpdateItem>(
    __namedParameters: WebxdcProviderOptions<I>,
): WebxdcProvider<I>

Properties§

§readonly awareness: Awareness

The awareness instance for ephemeral state (cursors, presence).

Methods§

Source§

destroy(): void

Release the resources held by the provider.

Call this when the provider is no longer needed, particularly in tests.

Since the webxdc API does not provide a way to unregister the webxdc update listener, we instead set a destroyed flag to ignore future webxdc updates.

Source§

onSaved(handler: () => void): void

Register a handler that gets fired whenever local changes are saved.

This means they are broadcast to chat peers.

Source§

onUpdated(handler: () => void): void

Register a handler that gets fired whenever a yjs change is detected.

Source§

syncToChatPeers(): void

Explicitly sync the chat to peers.

Normally this is called automatically by the autosave mechanism, so you do not need to call this manually.

Source§

syncToRealtimePeers(): void

Explicitly flush pending changes to the realtime channel.

Normally this is called automatically on the realtime interval, so you do not need to call this manually.