debounceTime method

ReactiveSubject<T> debounceTime(
  1. Duration duration
)

Emits items from the source ReactiveSubject only after a specified duration has passed without the ReactiveSubject emitting any other items.

Usage:

final subject = ReactiveSubject<String>();
final debounced = subject.debounceTime(Duration(seconds: 1));
debounced.stream.listen(print);
subject.add('a');
subject.add('b');
subject.add('c'); // After 1 second, prints: c

Implementation

ReactiveSubject<T> debounceTime(Duration duration) {
  final result = ReactiveSubject<T>();
  stream.debounceTime(duration).listen(result.add, onError: result.addError);
  return result;
}