rxdart icon indicating copy to clipboard operation
rxdart copied to clipboard

throttled stream ignores the close command

Open aurokk opened this issue 2 years ago • 1 comments
trafficstars

Hey! I was playing around with rxdart and faced a problem. When throttleTime is used then the stream ignores the close command. Is that by design or I'm doing sth wrong?

I use the latest versions of rxdart (0.27.7)/flutter (3.3.10) :-)

// WORKS

main() async {
  final c = StreamController<String>();
  Future.delayed(Duration(seconds: 5)).then((f) => c.close());
  final s = c.stream;
  print("start");
  await for (var _ in s) {
    print("loop");
  }
  print("end");
}

// WORKS

main() async {
  final c = StreamController<String>();
  Future.delayed(Duration(seconds: 5)).then((f) => c.close());
  final s = c.stream.debounceTime(Duration(seconds: 1));
  print("start");
  await for (var _ in s) {
    print("loop");
  }
  print("end");
}

// DOESN'T WORK, NEVER REACHES THE END

main() async {
  final c = StreamController<String>();
  Future.delayed(Duration(seconds: 5)).then((f) => c.close());
  final s = c.stream.throttleTime(Duration(seconds: 1));
  print("start");
  await for (var _ in s) {
    print("loop");
  }
  print("end");
}

aurokk avatar Jan 13 '23 18:01 aurokk

I guess, it is closed in 0.28.0...

ky1vstar avatar Mar 04 '25 17:03 ky1vstar