accordsync 0.3.2 copy "accordsync: ^0.3.2" to clipboard
accordsync: ^0.3.2 copied to clipboard

The Accord client for Dart - local-first writes, background sync, conflicts and refusals. Works in Flutter, CLI tools and servers.

accordsync #

The Accord client for Dart: local-first writes, background sync, conflicts and refusals.

Writes apply on the device at once and are saved; sync pushes them to the Accord server and pulls everyone else's. Each field merges by the rule you declare, so every device converges on the same data whatever order changes arrive in.

Pure Dart: works in Flutter (use accordsync_flutter for storage on the device and widgets), command-line tools and servers. It speaks the same protocol as the TypeScript client, so Dart and JavaScript devices sync together.

Use #

import 'package:accordsync/accordsync.dart';

final schema = defineSchema({
  'dossier': {'client_name': lww(), 'visits': counter(), 'docs': set(), 'status': conflict()},
});

final accord = await AccordClient.open(
  schema: schema,
  storage: MemoryStorage(), // or DriftStorage from accordsync_flutter
  transport: HttpTransport(url: 'https://sync.example.com', getToken: () => token),
);

await accord.inc('dossier:91', 'visits', 1); // saved locally, synced later
accord.start(); // sync after writes, every 30 s, with backoff while offline

accord.refusals.listen((r) => print('the server refused ${r.field}: ${r.reason}'));
print(accord.read('dossier:91'));
print(accord.conflicts());

What's inside #

  • AccordClient: open, assign, inc, add, remove, resolve, read, records, conflicts, status, sync, start/stop, close, and the streams changes, refusals, synced, resyncs and errors.
  • StorageAdapter (atomic load/commit) and MemoryStorage.
  • Transport and HttpTransport.

A write the server refuses (out of the user's scope, for example) is rolled back on the device and reported on refusals: never kept silently, never lost silently.

Docs: accord.benhattab.pro/docs · Source: crossben/accordsync-dart

0
likes
150
points
583
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

The Accord client for Dart - local-first writes, background sync, conflicts and refusals. Works in Flutter, CLI tools and servers.

Homepage
Repository (GitHub)
View/report issues

Topics

#offline-first #sync #crdt #local-first

License

Apache-2.0 (license)

Dependencies

accordsync_core, http

More

Packages that depend on accordsync