Class SyncedStorage

The SyncedStorage class manages the creation and synchronization of multiple storage instances over a WebSocket connection using Y.js and y-websocket.

Constructors

  • Creates an instance of SyncedStorage.

    Parameters

    • roomId: string

      The identifier for the room, used to segregate data within the server.

    • serverUrl: string

      The URL of the WebSocket server.

    Returns SyncedStorage

Properties

doc: Doc
provider: WebsocketProvider
roomId: string

The identifier for the room, used to segregate data within the server.

storage: Map<string, Storage<any>> = ...

Methods

  • Connects to or retrieves a named storage instance.

    Type Parameters

    • T extends SyncedStorageState

      The type of the synced storage state.

    Parameters

    • storageId: string

      Unique identifier for the storage instance.

    • initialState: T

      The initial state to be used for this storage if it's being created.

    Returns Storage<T>

    An instance of Storage.

  • Disconnects and disposes of the resources used by this SyncedStorage instance.

    Returns void

Generated using TypeDoc