Hi all,
I'm still trying to get my head around the async await syntax.
One thing that caught me by surprise, though perhaps I misunderstand, is that await expression by default does not "block" for streams.
I had assumed that the await expression when evaluated on a stream would return a list.
Here's an example of what I mean:
Stream<int> getResults() async* {
yield 42;
yield 43;
yield 44;
}
main() async {
var results = await getResults(); // This has no effect, need to write await getResults().toList();
print(results);
}
Another thing that took me a while to figure out is how to thread a timeout value through various calls to await. As in this example here:
I would be curious if anyone has advice on a cleaner way to do this.
The naive solution is to wrap a single timeout around the whole function - but I believe this could result in the async while loop continuing to run even after the timeout has expired - but I'm not sure about this. Sorry if the explanation isn't very clear - I'm still trying to understand this handy new feature ;)
Cheers,
Greg.