Skip to content

Commit

Permalink
computed_collections: CSTracker: Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mstniy committed Sep 22, 2024
1 parent d2cca24 commit 4c48e6c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/computed_collections/lib/src/utils/cs_tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ class CSTracker<K, V> {
} on NoValueException {
// pass
}
// We don't catch other exceptions here - instead assuming
// the snapshot stream would have thrown them.

// For the initial snapshot we always have to notify all streams
// as they have not been initialized yet.
if (sOld == null) {
// Even if change is null
return allStreams();
}
// We don't catch other exceptions here - instead assuming
// the snapshot stream would have thrown them.
// "push" the update to the relevant streams by returning them as our downstream
return switch (change) {
null => {},
return switch (change!) {
// As there is an older snapshot, there must be a change at this point
ChangeEventReplace<K, V>() => allStreams(),
KeyChanges<K, V>(changes: final changes) =>
(changes.length > _keyStreams.length + _valueStreams.length)
Expand Down

0 comments on commit 4c48e6c

Please sign in to comment.