0.4.0-rc.1: listen returns all previous values, not just latest
Andersmholmgren opened this issue · comments
Andersmholmgren commented
main() async {
final sc = new StreamController();
final p1 = new Property.fromStream(sc.stream);
sc.add('a');
sc.add('b');
await new Future.delayed(const Duration(milliseconds: 20));
listen(p1, 'p1');
await new Future.delayed(const Duration(milliseconds: 20));
}
listen(Reactable r, String l) => r.listen((v) => print('$l: $v'));
I expect to only see
p1: b
but I get
p1: a
p1: b
Dan Schultz commented
This is expected because of how single subscription controllers buffer their data. The controller won't start delivering its values until it has a listener.
Andersmholmgren commented
OK fair enough. I just had it in my head that a Property holds on to it's last value, not last several values so this took me by surprise.
Not necessarily a problem, I just need to adjust my thinking