accordsync_core

Accord's merge core for Dart: hybrid logical clocks, operations and the four merge strategies.

Pure Dart, no I/O. Most apps use accordsync or accordsync_flutter, which re-export it.

Strategy Merges by
lww() Highest hybrid logical clock wins.
counter() Sum of every increment; none is ever lost.
set() Add-wins set: a remove only removes what its writer had seen.
conflict() Concurrent values are all kept and the field is flagged; a resolution supersedes exactly the values its writer saw.
import 'package:accordsync_core/accordsync_core.dart';

final schema = defineSchema({
  'dossier': {'visits': counter(), 'status': conflict()},
});
final a = LocalWriter(schema: schema, deviceId: 'a', now: () => DateTime.now().millisecondsSinceEpoch);
final b = LocalWriter(schema: schema, deviceId: 'b', now: () => DateTime.now().millisecondsSinceEpoch);

b.receive(a.inc('dossier:1', 'visits', 2));
a.receive(b.inc('dossier:1', 'visits', 3));
print(a.replica.read('dossier:1')); // {visits: 5}

It merges byte for byte like @accordsync/core: the test suite runs the shared golden vectors in every delivery order, and random scenarios generated by the TypeScript core must produce identical snapshots here.

Docs: accord.benhattab.pro/docs/schema ยท Source: crossben/accordsync-dart

Libraries

accordsync_core
The Accord merge core: hybrid logical clocks, ops, the lww, counter, set and conflict strategies, and the replica. Pure Dart, no I/O; merges byte-for-byte like @accordsync/core.