Merge into package:async
We should consider merging this into https://pub.dev/packages/async
cc @natebosch
Also tracking at https://github.com/dart-lang/async/issues/117
Taking a note just in case - if we end up deciding not to do this for some reason (I don't expect we would) we should consider reviving https://github.com/dart-lang/site-www/pull/2974
@lrhn wdyt about merging this in as package:async/stream_transform.dart ?
I migth want to go through the operations a little more thoroughly before accepting them in package:async.
(A quick check showed the transformByHandlers's _defaultHandleValue does a runtime cast. I'd probably let it drop the value instead. Possibly have a different operation for transforming to the same type that defaults to preserving the value. I'm sure most of it is fine, but I'll want to make sure.)
A quick check showed the
transformByHandlers's_defaultHandleValuedoes a runtime cast. I'd probably let it drop the value instead.
The default callback isn't used outside of tests, and there it uses consistent types and doesn't need the cast. We can mark it required and avoid the misleading cast.
I checked more, and there are definitely things I'd want to update (using .wait instead of Future.wait, not checking if subscription.cancel() returns null, which it can't since 2.12, and maybe some restructuring of some of the code to make it work better with Stream.multi streams. And maybe optimizations.
I did try chaingng Future.value(initial).asStream() to Stream.value(intiial) in startWith. That broke some tests becuase of a difference in timing, so the tests may need to be made less timing sensitive, if the behavior cannot be.
(Not sure all combinations of broadcast/non-broadcast streams really make sense.)