Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update implementations of Stream.{lastWhere, firstWhere} for Dart 2 #311

Closed
leafpetersen opened this issue Mar 1, 2018 · 3 comments
Closed
Assignees

Comments

@leafpetersen
Copy link
Member

The current transitional state of lastWhere and firstWhere from lib/src/typed/stream.dart looks like this:

   Future<T> firstWhere(bool test(T element),  {Object defaultValue(), T orElse()}) =>
       _stream.firstWhere(_validateType(test), defaultValue: defaultValue ?? orElse);

We are deprecating (and will soon remove) the defaultValue argument. So at a minimum this code needs to be updated to:

   Future<T> firstWhere(bool test(T element),  {Object defaultValue(), T orElse()}) =>
       _stream.firstWhere(_validateType(test), orElse: orElse ?? () => defaultValue());

Presumably at some point we will want to deprecate and remove defaultValue from the TypeSafeStream API as well. Presumably we will need a major version bump when we remove it, since it's an API breaking change.

@nex3 would you prefer that I do this:

  • in one step
    • remove defaultValue entirely, bump the major version
  • in two steps
    • remove the delegating use of defaultValue but leave it in the API marked deprecated
    • at some later point (possibly as part of a collected major release) remove defaultValue
@nex3
Copy link
Member

nex3 commented Mar 1, 2018

TypeSafeStream isn't a public type—it's used behind-the-scenes by DelegatingStream.typed() to create a casting wrapper for a given stream. But now that Stream.cast() and friends exist, there's no need for typed() at all, in DelegatingStream or anywhere else in async. Probably the best thing to do is:

  • Delete all the TypeSafe* wrappers.
  • Update the static typed() methods to just call cast() on their arguments.
  • Mark them as deprecated and suggest users use cast() directly.
  • Bump the SDK constraint to whatever version first contained cast().

@leafpetersen
Copy link
Member Author

dart-archive/async#54

@leafpetersen
Copy link
Member Author

Landed.

@mosuem mosuem transferred this issue from dart-archive/async Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants