SyncManager constructor

SyncManager({
  1. required CRDTDocument document,
  2. required CRDTSocketClient client,
})

Keeps a CRDTDocument and a CRDTSocketClient in step.

It sends what the document writes locally, and applies what the server sends back.

Subscribes to CRDTDocument.localChanges at once; dispose ends it.

Implementation

SyncManager({
  required this.document,
  required this.client,
}) {
  // Listen to the local changes and send them to the server
  _localChangesSubscription =
      document.localChanges.listen(_handleLocalChange);
}