Skip to content

js-bao-wss-client


js-bao-wss-client / YjsPersistenceFactory

Type Alias: YjsPersistenceFactory()

YjsPersistenceFactory = (docId, ydoc, context) => YjsPersistenceProvider | null

Factory function for creating Yjs persistence providers.

Parameters

docId

string

The document ID being opened

ydoc

Doc

The Yjs document instance

context

YjsPersistenceContext

Additional context (appId, userId)

Returns

YjsPersistenceProvider | null

A persistence provider instance, or null to disable persistence

Example

ts
// Node.js with y-sqlite3
import { SqlitePersistence } from 'y-sqlite3';

const factory: YjsPersistenceFactory = (docId, ydoc, { appId, userId }) => {
  return new SqlitePersistence(docId, ydoc, {
    dbPath: `~/.my-app/${appId}/${userId}/yjs.sqlite`
  });
};