CRDT LF Hive

crdt_lf_hive_badge pub points pub likes codecov ci_badge License: MIT pub publisher

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.

Read the full documentation

πŸ“– 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 TypeAdapter each for Change and Snapshot
  • πŸͺͺ 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

Roadmap

Roadmap: done, in progress, to do

πŸ—ΊοΈ 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

Packages

Other bricks of the crdt "system" are:

Libraries

crdt_lf_hive
A Hive storage implementation for CRDT (Conflict-free Replicated Data Type) objects.