danschultz / stream_transformers

A Dart package for transforming streams
MIT License
12 stars 9 forks source link

FlatMapLatest example has same output as for FlatMap but shouldn't #35

Open chalin opened 8 years ago

chalin commented 8 years ago

The example is:

  var controller = new StreamController();
  var latest = controller.stream.transform(new FlatMapLatest((value) => new Stream.fromIterable([value + 1])));

  latest.listen(print);

  controller.add(1);
  controller.add(2); // Prints: 3

Running this sample code actually prints both 2 and 3, just like for FlatMap. Is this due to a bug in FlatMapLatest or bad sample code?

I'm running Dart 1.18.0 under macOS 10.11.

chalin commented 8 years ago

I noted a similar issue with RxJS 5 switchMap, see https://github.com/ReactiveX/rxjs/issues/1855. In that case too adding a delay "adjusted" the behavior too (as is done in #36). Maybe it is a question of event scheduling here as well, but I figured it might be easier to just tweak the example.