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

Replace Future.wait with Iterable<Future>.wait #188

Merged
merged 1 commit into from
Jun 17, 2024
Merged

Conversation

natebosch
Copy link
Contributor

@natebosch natebosch requested a review from lrhn June 13, 2024 19:31
@@ -138,7 +138,7 @@ extension AggregateSample<T> on Stream<T> {
// Handle opt-out nulls
cancels.removeWhere((Object? f) => f == null);
if (cancels.isEmpty) return null;
return Future.wait(cancels).then((_) => null);
return cancels.wait.then((_) => null);
Copy link
Contributor

@lrhn lrhn Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could all these (_) => null use the same top-level helper function, void voidCallback(void _) {}?
That should ensure we only have one function instance, instead of one per call point.

@@ -128,7 +128,7 @@ extension SwitchLatest<T> on Stream<Stream<T>> {
// Handle opt-out nulls
..removeWhere((Object? f) => f == null);
if (cancels.isEmpty) return null;
return Future.wait(cancels).then(_ignore);
return cancels.wait.then(_ignore);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be (_) => null like the rest, or use the same helper function.

@natebosch natebosch merged commit 37075a0 into master Jun 17, 2024
4 checks passed
@natebosch natebosch deleted the no-future-wait branch June 17, 2024 22:44
natebosch added a commit that referenced this pull request Jun 17, 2024
Add a `common_callbacks.dart` library with a single top level function
`ignoreArgument` which takes a single `dynamic` argument and does
nothing. Replace all `(_) => null` function literals, as well as a few
library-private functions with unnecessarily specific signatures, with
the shared definition.

As suggested in #188
natebosch added a commit that referenced this pull request Oct 19, 2024
Add a `common_callbacks.dart` library with a single top level function
`ignoreArgument` which takes a single `dynamic` argument and does
nothing. Replace all `(_) => null` function literals, as well as a few
library-private functions with unnecessarily specific signatures, with
the shared definition.

As suggested in #188
mosuem pushed a commit to dart-lang/tools that referenced this pull request Dec 11, 2024
mosuem pushed a commit to dart-lang/tools that referenced this pull request Dec 11, 2024
Add a `common_callbacks.dart` library with a single top level function
`ignoreArgument` which takes a single `dynamic` argument and does
nothing. Replace all `(_) => null` function literals, as well as a few
library-private functions with unnecessarily specific signatures, with
the shared definition.

As suggested in dart-archive/stream_transform#188
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants