stream_transform icon indicating copy to clipboard operation
stream_transform copied to clipboard

Merge into package:async

Open mit-mit opened this issue 5 years ago • 6 comments

We should consider merging this into https://pub.dev/packages/async

cc @natebosch

mit-mit avatar Jun 18 '20 11:06 mit-mit

Also tracking at https://github.com/dart-lang/async/issues/117

natebosch avatar Jun 18 '20 17:06 natebosch

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

natebosch avatar Feb 19 '21 23:02 natebosch

@lrhn wdyt about merging this in as package:async/stream_transform.dart ?

mit-mit avatar Jun 11 '24 11:06 mit-mit

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.)

lrhn avatar Jun 11 '24 11:06 lrhn

A quick check showed the transformByHandlers's _defaultHandleValue does 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.

natebosch avatar Jun 12 '24 23:06 natebosch

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.)

lrhn avatar Jun 13 '24 13:06 lrhn