Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
Drop checks for unsound null values (#189)
Browse files Browse the repository at this point in the history
Towards #111

During the null safety migration it was possible for
`StreamSubscription.cancel()` to return `null` in some cases. Now that
this package is only used with sound null safe code it isn't possible
for these nulls to flow through anymore so it is not necessary to filter
for them.
  • Loading branch information
natebosch authored Jun 18, 2024
1 parent 37075a0 commit 61754b7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 22 deletions.
2 changes: 0 additions & 2 deletions lib/src/aggregate_sample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ extension AggregateSample<T> on Stream<T> {
} else {
triggerSub!.pause();
}
// Handle opt-out nulls
cancels.removeWhere((Object? f) => f == null);
if (cancels.isEmpty) return null;
return cancels.wait.then((_) => null);
};
Expand Down
5 changes: 1 addition & 4 deletions lib/src/async_expand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ extension AsyncExpand<T> on Stream<T> {
}
controller.onCancel = () {
if (subscriptions.isEmpty) return null;
var cancels = [for (var s in subscriptions) s.cancel()]
// Handle opt-out nulls
..removeWhere((Object? f) => f == null);
return cancels.wait.then((_) => null);
return [for (var s in subscriptions) s.cancel()].wait.then((_) => null);
};
};
return controller.stream;
Expand Down
10 changes: 2 additions & 8 deletions lib/src/combine_latest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ extension CombineLatest<T> on Stream<T> {
var cancels = [
sourceSubscription!.cancel(),
otherSubscription!.cancel()
]
// Handle opt-out nulls
..removeWhere((Object? f) => f == null);
];
sourceSubscription = null;
otherSubscription = null;
return cancels.wait.then((_) => null);
Expand Down Expand Up @@ -230,11 +228,7 @@ extension CombineLatest<T> on Stream<T> {
}
controller.onCancel = () {
if (subscriptions.isEmpty) return null;
var cancels = [for (var s in subscriptions) s.cancel()]
// Handle opt-out nulls
..removeWhere((Object? f) => f == null);
if (cancels.isEmpty) return null;
return cancels.wait.then((_) => null);
return [for (var s in subscriptions) s.cancel()].wait.then((_) => null);
};
};
return controller.stream;
Expand Down
6 changes: 1 addition & 5 deletions lib/src/merge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ extension Merge<T> on Stream<T> {
}
controller.onCancel = () {
if (subscriptions.isEmpty) return null;
var cancels = [for (var s in subscriptions) s.cancel()]
// Handle opt-out nulls
..removeWhere((Object? f) => f == null);
if (cancels.isEmpty) return null;
return cancels.wait.then((_) => null);
return [for (var s in subscriptions) s.cancel()].wait.then((_) => null);
};
};
return controller.stream;
Expand Down
4 changes: 1 addition & 3 deletions lib/src/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ extension SwitchLatest<T> on Stream<Stream<T>> {
var cancels = [
if (!outerStreamDone) outerSubscription.cancel(),
if (sub != null) sub.cancel(),
]
// Handle opt-out nulls
..removeWhere((Object? f) => f == null);
];
if (cancels.isEmpty) return null;
return cancels.wait.then(_ignore);
};
Expand Down

0 comments on commit 61754b7

Please sign in to comment.