You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Perge` is a class containing references to `Automerge.Connections`, and encodes and decodes passed messages using `PeerJS` and the `Automerge.Connection` protocol.
|`actorId`|`string`| Unique ID used to initialize the PeerJS connection. Automerge should also be initialized with with this value. |
88
-
|`decode`|`(msg: string) => any`| A function called on a WebRTC string message before it is passed to an `Automerge.Connection` with `receiveMsg`, defaults to `JSON.parse`|
89
-
|`encode`|`(msg: any) => string`| A function called on `Automerge.DocSet` change objects before it is sent to a peer, defaults to `JSON.stringify`|
90
-
|`peerInstance`|`PeerJS.Peer`| A preconfigured `PeerJS.Peer` instance. |
91
-
|`docSet`|`Automerge.DocSet<T>`| An instantiated `Automerge.DocSet` to sync between clients. |
86
+
You can further configure `Perge` with the following config shape. All properties are optional.
|`decode`|`(msg: string) => any`| A function called on a WebRTC string message before it is passed to an `Automerge.Connection` with `receiveMsg`, defaults to `JSON.parse`|
91
+
|`encode`|`(msg: any) => string`| A function called on `Automerge.DocSet` change objects before it is sent to a peer, defaults to `JSON.stringify`|
92
+
|`peer`|`PeerJS.Peer`| A preconfigured `PeerJS.Peer` instance. |
93
+
|`docSet`|`Automerge.DocSet<T>`| An instantiated `Automerge.DocSet` to sync between clients. |
94
94
95
-
Getter that retrieves the sync'd `Automerge.DocSet`, handy to subscribe to state changes with:
95
+
96
+
#### `readonly docSet: Automerge.DocSet<any>;`
97
+
98
+
A reference to the synchronized `Automerge.DocSet`, handy to subscribe to state changes with if you don't want to use `Perge.subscribe`:
Returns a function that applies a given `Automerge` doc method, then sets the returned document on the internal `DocSet` to broadcast changes to connected peers, for example:
Returns a function that applies a given `Automerge` document change method, then sets the returned document on the internal `DocSet` to broadcast changes to connected peers, for example:
0 commit comments