dart-lang / site-www

Source for Dart website
https://dart.dev
Other
967 stars 696 forks source link

Provide an example for transforming a Stream #4322

Open iLoveDocs opened 1 year ago

iLoveDocs commented 1 year ago

What information is missing?

The CONSIDER using higher-order methods to transform a stream. section mentions:

Streams support many of the same methods and also handle things like transmitting errors, closing, etc. correctly.

It would be nice to provide some examples.

How would you like us to fix this problem?

An example could be:

var intStream = Stream.fromIterable([1, 2, 3]); // Stream<int>
var boolStream = intStream.map((n) => n.isEven); // Stream<bool>
MaryaBelanger commented 1 year ago

This page is probably a little out of date, but might help? https://dart.dev/articles/libraries/creating-streams (I didn't actually check myself, so let us know if it's lacking)

parlough commented 1 year ago

I agree, it would be nice to expand on this section, rather than just pointing to another one, so that the rule can be absorbed in isolation.