crdt_lf_drift 0.3.3
crdt_lf_drift: ^0.3.3 copied to clipboard
drift storage adapter for CRDT LF library objects, providing persistence for Change and Snapshot objects.
CRDT LF Drift #
A Drift storage adapter for crdt_lf:
it keeps your documents on the device, and reads them back on launch. Pick it when your app already uses Drift.
π The full persistence guide β which adapter to pick, history, backups, compaction β is on mattiapispisa.it/crdt.
Features #
- ποΈ One database, many documents: three tables, with schema migrations
- π Real transactions: a compaction lands all at once or not at all
- β³ Asynchronous end to end, like the rest of Drift
- π Your executor: wrap a
CRDTDriftDatabaseon theQueryExecutoryou choose - π Web: pass a Drift web database to
CRDTDrift.fromDatabase - πͺͺ Peer identity: the device writes under the same author on every launch
- π§© Same contract as the Hive and SQLite adapters: change backend with one line
- β β¦and more: everything else is in the documentation
Quick start #
dart pub add crdt_lf crdt_lf_drift
import 'dart:io';
import 'package:crdt_lf/crdt_lf.dart';
import 'package:crdt_lf_drift/crdt_lf_drift.dart';
final backend = CRDTDrift.open(File('note.db'));
// Reads the stored note (or starts an empty one), then writes every edit.
final note = await backend.openDocument('note');
final text = CRDTFugueTextHandler(note.document, 'body');
text.insert(text.value.runes.length, 'Hello π\n');
await note.persistence.dispose(); // writes what is still waiting
note.document.dispose();
await note.persistence.storage.close();
await backend.close();
Every change is written down from there on: the complete program, tested in
CI, is the recipe. This package re-exports the whole
crdt_lf_persistence API, so it
is the only storage package your pubspec.yaml needs.
Documentation #
- Which adapter: Hive, SQLite, Drift, β¦
- Drift: setup and storage details
- Working with storage: history, backups, compaction, β¦
- Open a replica: storage and sync together
Roadmap #
πΊοΈ The project board shows what is done, what is in progress and what comes next, for this package and the rest of the workspace. Missing something? Open an issue: requests go on the board too.
Apps #
- greyhound_markdown β Real-time collaborative markdown editor built on crdt_lf
Packages #
Other bricks of the crdt "system" are: