@wordpress/sync

Sync data between multiple peers and persist in a local database.

Installation

Install the module

npm install @wordpress/sync --save

API

connectIndexDb

Connect function to the IndexedDB persistence provider.

Parameters

  • objectId ObjectID: The object ID.
  • objectType ObjectType: The object type.
  • doc CRDTDoc: The CRDT document.

Returns

  • Promise<() => void>: Promise that resolves when the connection is established.

createSyncProvider

Create a sync provider.

Parameters

  • connectLocal ConnectDoc: Connect the document to a local database.
  • connectRemote ConnectDoc: Connect the document to a remote sync connection.

Returns

  • SyncProvider: Sync provider.

createWebRTCConnection

Function that creates a new WebRTC Connection.

Parameters

  • config Object: The object ID.
  • config.signaling Array<string>:
  • config.password string:

Returns

  • Function: Promise that resolves when the connection is established.

Contributing to this package

This is an individual package that’s part of the Gutenberg project. The project is organized as a monorepo. It’s made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project’s main contributor guide.