Creating Streams With async*
Yield events from a generator.
Producing Your Own Streams
So far you consumed streams others made. Now you will produce them yourself using an async generator, the cleanest way to emit events.
The async* Keyword
Mark a function async* and it becomes a stream generator. Its return type is a Stream, and it can emit values over time. 🚿
Stream<int> countTo(int n) async* {
// body uses yield
}All lessons in this course
- Listening With await for
- Single vs Broadcast Streams
- Transforming Streams: map, where, take
- Creating Streams With async*