danschultz / frappe

A Dart package for functional reactive programming

Home Page:http://pub.dartlang.org/packages/frappe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.4.0-rc.1: listen returns all previous values, not just latest

Andersmholmgren opened this issue · comments

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

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.

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