@wordpress/sync
Version:
67 lines (37 loc) • 1.85 kB
Markdown
# Sync
Sync data between multiple peers and persist in a local database.
## Installation
Install the module
```bash
npm install @wordpress/sync --save
```
## API
<!-- START TOKEN(Autogenerated API docs) -->
### 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.
<!-- END TOKEN(Autogenerated API docs) -->
## 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](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) 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](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>