throttle method

Stream<T> throttle(
  1. Duration duration
)

Emits the first event of each duration window and suppresses the rest (throttle).

Implementation

Stream<T> throttle(Duration duration) {
  var suppressed = false;
  return where((_) {
    if (suppressed) return false;
    suppressed = true;
    Timer(duration, () => suppressed = false);
    return true;
  });
}