Websocket Provider for Yjs. Creates a websocket connection to sync the shared document. The document name is attached to the provided url. I.e. the following example creates a websocket connection to http://localhost:1234/my-document-name

Example

import * as Y from 'yjs'
import { YSweetProvider } from 'y-websocket'
const doc = new Y.Doc()
const provider = new YSweetProvider('http://localhost:1234', 'my-document-name', doc)

Hierarchy

  • Observable<string>
    • YSweetProvider

Constructors

Properties

_WS: WebSocketPolyfillType
_awarenessUpdateHandler: Function
_bcSubscriber: Function
_checkInterval: number | Timer
_observers: Map<string, any>

Some desc.

_resyncInterval: number | Timer
_synced: boolean
_unloadHandler: Function
_updateHandler: ((arg0, arg1, arg2, arg3) => void)

Type declaration

    • (arg0, arg1, arg2, arg3): void
    • Parameters

      • arg0: Uint8Array
      • arg1: any
      • arg2: Doc
      • arg3: Transaction

      Returns void

awareness: Awareness
bcChannel: string
bcconnected: boolean
disableBc: boolean
doc: Doc
maxBackoffTime: number
messageHandlers: HandlerFunction[]
onFailureHandlers: (() => void)[] = []

Type declaration

    • (): void
    • Returns void

roomname: string
shouldConnect: boolean
url: string
ws: null | WebSocket
wsLastMessageReceived: number
wsUnsuccessfulReconnects: number
wsconnected: boolean
wsconnecting: boolean

Accessors

Methods

  • Parameters

    • handler: (() => void)
        • (): void
        • Returns void

    Returns (() => void)

      • (): void
      • Returns void

  • Emit a named event. All registered event listeners that listen to the specified name will receive the event.

    Parameters

    • name: string

      The event name.

    • args: any[]

      The arguments that are applied to the event listener.

    Returns void

    Todo

    This should catch exceptions

  • Parameters

    • name: string
    • f: Function

    Returns void

  • Parameters

    • name: string
    • f: Function

    Returns void

  • Parameters

    • name: string
    • f: Function

    Returns void