hive_crdt 3.1.2 copy "hive_crdt: ^3.1.2" to clipboard
hive_crdt: ^3.1.2 copied to clipboard

Dart implementation of Conflict-free Replicated Data Types (CRDTs), backed by a Hive store.

example/example.dart

import 'package:hive/hive.dart';
import 'package:hive_crdt/src/hive_adapters.dart';
import 'package:hive_crdt/src/hive_crdt.dart';

Future<void> main() async {
  // Initialize Hive
  Hive
    ..init('test_store')
    ..registerAdapter(RecordAdapter(42));

  var crdt1 = await HiveCrdt.open(prefix: 'crdt1', ['table']);
  var crdt2 = await HiveCrdt.open(prefix: 'crdt2', ['table']);

  print('Inserting 2 records in crdt1…');
  await crdt1.put('table', 'a', 1);
  await crdt1.put('table', 'b', 1);

  print('crdt1: ${crdt1.getMap('table')}');

  print('\nInserting a conflicting record in crdt2…');
  await crdt2.put('table', 'a', 2);

  print('crdt2: ${crdt2.getMap('table')}');

  print('\nMerging crdt2 into crdt1…');
  await crdt1.merge(crdt2.getChangeset());

  print('crdt1: ${crdt1.getMap('table')}');
}
7
likes
160
points
112
downloads

Publisher

verified publishercachapa.net

Weekly Downloads

Dart implementation of Conflict-free Replicated Data Types (CRDTs), backed by a Hive store.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

crdt, hive

More

Packages that depend on hive_crdt