CRDT LF Hive
A Hive storage adapter for crdt_lf:
it keeps your documents on the device, and reads them back on launch. It runs on the web with no setup.
π The full persistence guide β which adapter to pick, history, backups, compaction β is on mattiapispisa.it/crdt.
Features
- π Runs everywhere: Dart VM, Flutter, and the web
- β‘ Synchronous reads: a box is in memory, so a document is restored before the first frame
- ποΈ Boxes per document, plus a small registry of document ids
- π€ Shared boxes: a box closes with its last user, so two replicas can share them
- π¦ Compact binary: one
TypeAdaptereach forChangeandSnapshot - πͺͺ Peer identity: the device writes under the same author on every launch
- π§© Same contract as the SQLite and Drift adapters: change backend with one line
- β β¦and more: everything else is in the documentation
Quick start
flutter pub add crdt_lf crdt_lf_hive hive path_provider
// On the web Hive uses IndexedDB and needs no path.
if (!kIsWeb) {
Hive.init((await getApplicationDocumentsDirectory()).path);
}
CRDTHive.initialize();
// One backend for the whole app: it lives as long as the app does.
final backend = await CRDTHive.open();
Then backend.openDocument('note') reads a document back and follows it. The
complete app, a text field saved on the device and tested in CI, is the
recipe.
Every change is written down from there on. This package re-exports the whole
crdt_lf_persistence API, so it
is the only storage package your pubspec.yaml needs.
Greyhound Markdown keeps its rooms in the browser with this adapter.
Documentation
- Which adapter: Hive, SQLite, Drift, β¦
- Hive: 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:
Libraries
- crdt_lf_hive
- A Hive storage implementation for CRDT (Conflict-free Replicated Data Type) objects.