@wordpress/sync
Version:
54 lines (28 loc) • 1.95 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) -->
### CRDT_DOC_META_PERSISTENCE_KEY
CRDT documents can hold meta information in a map. This map exists only in memory and is not synced or persisted. This key can be used to indicate that a (temporary) document has been loaded from persistence.
### CRDT_RECORD_MAP_KEY
Root-level key for the CRDT document that holds the entity record data.
### createSyncManager
The sync manager orchestrates the lifecycle of syncing entity records. It creates Yjs documents, connects to providers, creates awareness instances, and coordinates with the `core-data` store.
### LOCAL_EDITOR_ORIGIN
Origin string for CRDT document changes originating from the local editor.
### LOCAL_SYNC_MANAGER_ORIGIN
Origin string for CRDT document changes originating from the sync manager.
### WORDPRESS_META_KEY_FOR_CRDT_DOC_PERSISTENCE
WordPress meta key used to persist the CRDT document for an entity.
### Y
Exported copy of Yjs so that consumers of this package don't need to install it.
<!-- 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>