dart - Await on stream to pulse x time before continuing -


simple dart problem, got stream

stream<event> 

i subscribe in unit test. this:

stream.listen(listener) await listenerbeennotified5times expect(result,expectation) 

i know expectasync can used make sure notification happens 5 times, want wait pause execution until 5 events have been streamed.

var s = stream.take(5); var subscription = s.listen(listener); await susciption.asfuture; 

or

await stream.take(5).tolist(); 

Comments