Open lrhn opened 5 years ago
Hi,
Guys, do you have any estimation regarding this issue?
I faced with the issue while I used this bloc library and I wasn't able to control when the state machine changes its state. My workaround is to not use yield*
:(
Let me drop in an example in pure dart:
import 'dart:async';
int latestValue = 0;
Stream<int> func1() async* {
yield* func2();
}
Stream<int> func2() async* {
yield 1;
print(latestValue); // prints "0", but "1" expected
yield 2;
print(latestValue); // "1"
}
void main() {
func1().listen((i) => latestValue = i);
}
The
async*
functionyield
is specified to wait until the event has been delivered, giving the receiver time to pause or cancel in (immediate) response to receiving the event.Implementations do not wait for the receiver. This makes it hard and inefficient to write
async*
functions that do not do too much work. The implementations should follow the specification and make the user experience better.Associated feature specification has more details.