Skip to content

Commit a9bd6b0

Browse files
author
Giorgio Franceschetti
committed
Follow Up Change Events Improvements
1 parent 8cf7329 commit a9bd6b0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

example/manual/watch/watch_on_collection.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ void main() async {
6363
/// As the stream does not end until it is closed, do not use .toList()
6464
/// or you will wait indefinitely
6565
var controller = stream.listen((changeEvent) {
66-
Map fullDocument = changeEvent.fullDocument;
66+
Map<String, dynamic> fullDocument =
67+
changeEvent.fullDocument ?? <String, dynamic>{};
6768

6869
print('Detected change for "custId" '
6970
'${fullDocument['custId']}: "${fullDocument['name']}"');

example/manual/watch/watch_on_collection_insert.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ void main() async {
5050
/// As the stream does not end until it is closed, do not use .toList()
5151
/// or you will wait indefinitely
5252
var controller = stream.listen((changeEvent) {
53-
Map fullDocument = changeEvent.fullDocument;
53+
Map<String, dynamic> fullDocument =
54+
changeEvent.fullDocument ?? <String, dynamic>{};
5455

5556
print('Detected change for "custId" '
5657
'${fullDocument['custId']}: "${fullDocument['name']}"');

test/op_msg_read_operation_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,8 @@ db.runCommand(
18781878

18791879
var aResult = 3;
18801880
var controller = stream.listen((changeEvent) {
1881-
Map fullDocument = changeEvent.fullDocument;
1881+
Map<String, dynamic> fullDocument =
1882+
changeEvent.fullDocument ?? <String, dynamic>{};
18821883

18831884
expect(fullDocument['a'], aResult++);
18841885

0 commit comments

Comments
 (0)