-
Notifications
You must be signed in to change notification settings - Fork 50
Deprecate DelegatingStream.typed and make it delegate to Stream.cast #54
Conversation
This is great! Do you mind doing the same for the other |
We didn't add cast/retype to Future and StreamSubscription, so we can't do quite the same thing. For the Future case, using static Future<T> typed<T>(Future future) =>
future is Future<T> ? future : future.then((x) => x as T); does the right thing typing wise, I think, but it doesn't handle the unwrapping/rewrapping if you cast it again. |
@@ -1,5 +1,5 @@ | |||
name: async | |||
version: 2.0.5 | |||
version: 2.0.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this available in -dev.23?
Do we need to bump the SDK constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these APIs were available in dev.23, and all tests for this package pass with dev.23.
Just pushed a patch removing internal uses of the now deprecated .typed method, and also ran the formatter. |
Why not? It may be useful to be able to cast the type argument of pretty much any generic class. If we can't get rid of all the |
I don't know, I wasn't part of the design discussions for these. @lrhn maybe knows?
Ok, will do. |
This reverts commit 6f3e6fc.
Done, PTAL. |
[skip ci]
Thanks Leaf! |
Thanks, and thanks for publishing! |
We had to stop somewhere, and there didn't seem to be any cases where these were needed. The The Also, the int x = await numFuture;
await for (int y in numStream) .... without needing to cast the future or collection first, even if you can't do So, basically, we didn't think it was worth the API complexity to add the feature. It was always mainly an |
I removed stream_test.dart since all of the functionality is really part of the SDK implementation of Stream.cast now, but if you'd prefer me to keep it around let me know.