File tree Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change
1
+ ## 5.0.2
2
+ - Add convenience function to parse over-the-wire changesets
3
+
1
4
## 5.0.1
2
5
- Fix dependency compatibility with the Flutter SDK
3
6
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ abstract mixin class Crdt {
90
90
}
91
91
}
92
92
93
+ /// Thrown on merge errors. Contains the failed payload to help with debugging
94
+ /// large datasets.
93
95
class MergeError <T > {
94
96
final T error;
95
97
final String table;
Original file line number Diff line number Diff line change
1
+ import 'hlc.dart' ;
2
+
1
3
typedef CrdtRecord = Map <String , Object ?>;
2
4
typedef CrdtTableChangeset = List <CrdtRecord >;
3
5
typedef CrdtChangeset = Map <String , CrdtTableChangeset >;
4
6
7
+ /// Utility function to simplify parsing untyped changesets.
8
+ /// It performs all necessary casts to satisfy Dart's type system, and parses
9
+ /// Hlc timestamps.
10
+ /// Useful when receiving datasets over the wire.
11
+ CrdtChangeset parseCrdtChangeset (Map <String , dynamic > message) =>
12
+ // Cast payload to CrdtChangeset
13
+ message.map ((table, records) => MapEntry (
14
+ table,
15
+ (records as List )
16
+ .cast <Map <String , dynamic >>()
17
+ // Parse Hlc
18
+ .map ((e) => e.map ((key, value) =>
19
+ MapEntry (key, key == 'hlc' ? Hlc .parse (value) : value)))
20
+ .toList ()));
21
+
5
22
extension CrdtChangesetX on CrdtChangeset {
6
23
/// Convenience method to get number of records in a changeset
7
24
int get recordCount => values.fold <int >(0 , (prev, e) => prev + e.length);
Original file line number Diff line number Diff line change 1
1
name : crdt
2
2
description : Dart implementation of Conflict-free Replicated Data Types (CRDTs).
3
- version : 5.0.1
3
+ version : 5.0.2
4
4
homepage : https://github.com/cachapa/crdt
5
5
repository : https://github.com/cachapa/crdt
6
6
issue_tracker : https://github.com/cachapa/crdt/issues
@@ -9,7 +9,7 @@ environment:
9
9
sdk : ' >=3.0.0 <4.0.0'
10
10
11
11
dependencies :
12
- # Prevent ongoing dependency issues since this package is bundled in the Flutter SDK
12
+ # Prevent ongoing dependency issues since this package is bundled with the Flutter SDK
13
13
meta : ' >=1.0.0 <2.0.0'
14
14
uuid : ^4.0.0
15
15
You can’t perform that action at this time.
0 commit comments