dart-lang / stream_transform

Dart utility methods to create StreamTransfomer instances to manipulate Streams
https://pub.dev/packages/stream_transform
BSD 3-Clause "New" or "Revised" License
123 stars 21 forks source link

Make transformToHandlers public #129

Open kanapin opened 3 years ago

kanapin commented 3 years ago

Hello folks,

Currently transformFromHandlers isn't exported in lib/stream_transform.dart. Is it possible to expose it?

It's better than the standard fromHandlers transformer in the sense that it allows relying on a common state for broadcast streams since callbacks are called once per event only.

natebosch commented 3 years ago

cc @lrhn for thoughts.

The utility is:

https://github.com/dart-lang/stream_transform/blob/053711699fe0163c8106ea544729f5058e610ff3/lib/src/from_handlers.dart#L7-L16

I can see value in exposing this. If we decide we do want to expose it we should consider the naming (I wasn't careful about that as an internal detail), as well as wether an extension method is the right API (I think it is).

lrhn commented 3 years ago

It seems useful, so sure, why not.

Naming is hard.... let's go shopping. All the good names are taken! 😁

It should be named something with transform. Maybe just transformEvents. It doesn't transform the stream into a separate stream, but the events into different events (which is potatoe/potatoh really, but might make sense to the user anyway). It also matches, to me, with that each event is only transformed once,