import method
bool
import({
- required VersionVector serverVersionVector,
- List<
Change> ? changes, - Snapshot? snapshot,
CRDTDocument.import with:
merge: falsepruneHistory: true
Returns whether the state went in. On false nothing is sent back: this
peer never took the server's state, so what it holds is not an answer.
A failure becomes a SyncFault.
Reported on CRDTSocketClient.faults, never thrown: this runs inside the
callback that reads the socket, where a throw reaches no catch and no
onError and ends up as an uncaught error in the zone.
Implementation
bool import({
required VersionVector serverVersionVector,
List<Change>? changes,
Snapshot? snapshot,
}) {
try {
document.import(
changes: changes,
snapshot: snapshot,
);
} catch (error, stackTrace) {
client.reportSyncFault(
SyncFault(
reason: 'Could not import the state the server served',
error: error,
stackTrace: stackTrace,
),
);
return false;
}
_sendUnknownChangesToServerSync(
document.exportChangesNewerThan(serverVersionVector),
);
return true;
}