From ef304abf12c6542095f828cbe699d0422025e998 Mon Sep 17 00:00:00 2001 From: Daniel Cachapa Date: Thu, 14 Sep 2023 21:26:04 +0200 Subject: [PATCH] Update example --- CHANGELOG.md | 27 +++++++++++++++++++++ README.md | 6 ++--- example/{crdt_example.dart => example.dart} | 2 +- pubspec.yaml | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) rename example/{crdt_example.dart => example.dart} (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 402f146..9572674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,20 @@ +## 5.1.0 + +- Fix `Hlc` in Dart web +- Breaking: replaced `millis` time representation with `DateTime` object +- Breaking: removed `logicalTime` operators from `Hlc` since they failed silently in 32-bit environments +- Add `watch` method to `MapCrdtBase` + ## 5.0.2 + - Add convenience function to parse over-the-wire changesets ## 5.0.1 + - Fix dependency compatibility with the Flutter SDK ## 5.0.0 + This version introduces a major refactor which results in multiple breaking changes. This was done with the intention to make this package the basis for a family of CRDT libraries. Another motivation was to make this package compatible with [crdt_sync](https://github.com/cachapa/crdt_sync), thereby abstracting the communication protocol and network management for real-time remote synchronization. @@ -16,18 +26,23 @@ Changes: - Reimplemented CrdtMap as a zero-dependency implementation ## 4.0.3 + - Update to Dart 3 ## 4.0.2 + - Add purge() method to reset the data store ## 4.0.1 + - Fix edge case when merging remote records ## 4.0.0 + - Migrate to Dart null safety ## 3.0.0 + - Use milliseconds instead of microseconds for HLCs - Allow using non-string node ids - Allow watching for changes @@ -37,19 +52,24 @@ Changes: - Move HiveCrdt project to its own repo: https://github.com/cachapa/hive_crdt ## 2.2.2 + - Hlc: Add convenience `fromDate` constructor - HiveCrdt: Fix NPE when getting a non-existing record ## 2.2.1 + - Crdt: Fix encoder return type ## 2.2.0 + - Crdt: Pass keys to map encoder and decoder, useful to disambiguate when parsing ## 2.1.1 + - Crdt: Fix HLC timestamp generation for dart-web ## 2.1.0 + - Hlc: Add `const` keywords to constructors wherever possible - Crdt: Expose canonical time - Crdt: Add convenience methods (isEmpty. length, etc.) @@ -64,6 +84,7 @@ Changes: - HiveCrdt: Fix DateTime key serialization ## 2.0.0 + - Remove CrdtStore. - Make Crdt abstract. - Remove watches (they can be added in subclasses - see HiveCrdt). @@ -71,13 +92,16 @@ Changes: - Add HiveCrdt as a submodule, A CRDT backed by a [Hive](https://pub.dev/packages/hive) store. ## 1.2.2 + - Fix incrementing the HLC when merging newer records. - Fix counter not being able to reach maximum (0xFFFF) ## 1.2.1 + - Remove unnecessary Future in `Crdt.values` getter. ## 1.2.0 + - Breaking: `Crdt.get()` now returns the value (or `null`) rather than the record. Use `Crdt.getRecord()` for the previous behaviour. - API Change: Getter methods on both `Crdt` and `Store` are now synchronous. - API Change: `Crdt.Clear()` now accepts `purgeRecords` to determine if records should be purged or marked as deleted. @@ -85,9 +109,11 @@ Changes: - Add `Crdt.isDeleted()` to check if a record has been deleted. ## 1.1.1 + - Add values getter which retrieves all values as list, excluding deleted records ## 1.1.0 + - HLCs implement Comparable - Support typed key and values - Refactor CRDT and Store to replace index operators with getters and setters @@ -95,4 +121,5 @@ Changes: - Add JSON de/serialisation helper methods ## 1.0.0 + - Initial version diff --git a/README.md b/README.md index 6344217..1dc8d87 100644 --- a/README.md +++ b/README.md @@ -29,17 +29,17 @@ void main() { crdt1.put('table', 'a', 1); crdt1.put('table', 'b', 1); - print('crdt1: ${crdt1.get('table')}'); + print('crdt1: ${crdt1.getMap('table')}'); print('\nInserting a conflicting record in crdt2…'); crdt2.put('table', 'a', 2); - print('crdt2: ${crdt2.get('table')}'); + print('crdt2: ${crdt2.getMap('table')}'); print('\nMerging crdt2 into crdt1…'); crdt1.merge(crdt2.getChangeset()); - print('crdt1: ${crdt1.get('table')}'); + print('crdt1: ${crdt1.getMap('table')}'); } ``` diff --git a/example/crdt_example.dart b/example/example.dart similarity index 90% rename from example/crdt_example.dart rename to example/example.dart index 15b5250..84e709b 100644 --- a/example/crdt_example.dart +++ b/example/example.dart @@ -1,4 +1,4 @@ -import 'package:crdt/src/map_crdt/map_crdt.dart'; +import 'package:crdt/map_crdt.dart'; void main() { var crdt1 = MapCrdt(['table']); diff --git a/pubspec.yaml b/pubspec.yaml index d5cf271..bf56c42 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: crdt description: Dart implementation of Conflict-free Replicated Data Types (CRDTs). -version: 5.0.2 +version: 5.1.0 homepage: https://github.com/cachapa/crdt repository: https://github.com/cachapa/crdt issue_tracker: https://github.com/cachapa/crdt/issues