WeaveStoreAzureWebPubsub
API reference for WeaveStoreAzureWebPubsub class
Overview
The WeaveStoreAzureWebPubsub class is a client-side store in the Weave.js Azure Web PubSub store that enables real-time collaboration via Azure Web PubSub. It connects to a backend powered by WeaveAzureWebPubsubServer, using Yjs under the hood to handle conflict-free data syncing and user awareness.
This store allows your Weave.js-based frontend application to join a collaborative session, share state with other users, and reflect live updates instantly—all while leveraging the scalability and reliability of Azure’s managed infrastructure.
Import
import { WeaveStoreAzureWebPubsub } from "@inditextech/weave-store-azure-web-pubsub/client";
Instantiation
const store = new WeaveStoreAzureWebPubsub(storeOptions: WeaveStoreOptions, azureWebPubsubOptions: WeaveStoreAzureWebPubsubOptions);
Parameters
Prop | Type | Default |
---|---|---|
websocketOptions.callbacks? | WeaveStoreWebsocketsCallbacks | {} |
websocketOptions.wsOptions | { serverUrl: string; } | - |
websocketOptions.roomId | string | - |
storeOptions.undoManagerOptions? | WeaveUndoManagerOptions | - |
storeOptions.getUser | () => WeaveUser | - |
TypeScript types
type WeaveStoreWebsocketsConnectionStatusKeys =
keyof typeof WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS;
type WeaveStoreWebsocketsConnectionStatus =
(typeof WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS)[WeaveStoreWebsocketsConnectionStatusKeys];
type WeaveStoreWebsocketsCallbacks = {
onConnectionStatusChange?: (
status: WeaveStoreWebsocketsConnectionStatus
) => void;
};
type WeaveUser = {
name: string;
email: string;
};
type WeaveUndoManagerOptions = {
captureTimeout?: number;
trackedOrigins?: Set<any>;
};
type WeaveStoreOptions = {
getUser: () => WeaveUser;
undoManagerOptions?: WeaveUndoManagerOptions;
};
type WeaveStoreWebsocketsOptions = {
roomId: string;
wsOptions: {
serverUrl: string;
};
callbacks?: WeaveStoreWebsocketsCallbacks;
};
Events
onStateChange
onStateChange: WeaveStoreOnStateChangeEvent;
The onStateChange
event is called when the shared-state changes.
onRoomLoaded
onRoomLoaded: WeaveStoreOnRoomLoadedEvent;
The onRoomLoaded
event is called when the room shared-state is loaded.
onUndoManagerStatusChange
onUndoManagerStatusChange: WeaveStoreOnUndoRedoChangeEvent;
The onUndoManagerStatusChange
event is called when the undo/redo manager changes.
onNodeChange
onNodeChange: WeaveStoreOnNodeChangeEvent;
The onNodeChange
event is called when there is a single node selected and the node changes.
Methods
connect
connect(): void
The connect
method is called when an user tries to join a room.
disconnect
disconnect(): void
The disconnect
method is called when an user leaves a room.
setAwarenessInfo
setAwarenessInfo(field: string, value: unknown): void
This method set awareness information, for example if you want to inform the metadata of an user that connected to the room, or to send the pointer information of that user to the other peers.