wsProvider = new WebsocketProvider(serverUrl: string, room: string, ydoc: Y.Doc [, wsOpts: WsOpts])Create a new websocket-provider instance. As long as this provider, or the connected
ydoc, is not destroyed, the changes will be synced to other clients via the connected server. Optionally, you may specify a configuration object. The following default values of
wsOptscan be overwritten.
wsProvider.wsconnected: booleanTrue if this instance is currently connected to the server.
wsProvider.wsconnecting: booleanTrue if this instance is currently connecting to the server.
wsProvider.shouldConnect: booleanIf false, the client will not try to reconnect.
wsProvider.synced: booleanTrue if this instance is currently connected and synced with the server.
wsProvider.disconnect()Disconnect from the server and don't try to reconnect.
wsProvider.connect()Establish a websocket connection to the websocket-server. Call this if you recently disconnected or if you set
wsOpts.connect = false.
wsProviderinstance. Disconnects from the server and removes all event handlers.
wsProvider.on('sync', function(isSynced: boolean))Add an event listener for the
syncevent that is fired when the client received content from the server.
y-websocket-serverexecutable from your local
./node_modules/.binfolder, you can simply run npx. The
PORTenvironment variable defaults to 1234.
POST) on document update.
CALLBACK_URL: Callback server URL
CALLBACK_DEBOUNCE_WAIT: Debounce time between callbacks (in ms). Defaults to 2000 ms
CALLBACK_DEBOUNCE_MAXWAIT: Maximum time to wait before the callback. Defaults to 10 seconds
CALLBACK_TIMEOUT: Timeout for the HTTP call. Defaults to 5 seconds
CALLBACK_OBJECTS: JSON of shared objects to get data (
localhost:30002 seconds after receiving an update (default
DEBOUNCE_WAIT) with the data of an XmlFragment named
"prosemirror"in the body.