RateLimit<T> extension

Utilities to rate limit events.

  • debounce - emit the the first or last event of a series of closely spaced events.
  • debounceBuffer - emit all events at the end of a series of closely spaced events.
  • throttle - emit the first event at the beginning of the period.
  • audit - emit the last event at the end of the period.
  • buffer - emit all events on a trigger.
on

Methods

audit(Duration duration) Stream<T>
Audit a single event from each duration length period where there are events on this stream.
buffer(Stream<void> trigger, {bool longPoll = true}) Stream<List<T>>
Buffers the values emitted on this stream and emits them when trigger emits an event.
debounce(Duration duration, {bool leading = false, bool trailing = true}) Stream<T>
Suppresses events with less inter-event spacing than duration.
debounceBuffer(Duration duration) Stream<List<T>>
Buffers values until this stream does not emit for duration then emits the collected values.
sample(Stream<void> trigger, {bool longPoll = true}) Stream<T>
Emits the most recent new value from this stream when trigger emits an event.
throttle(Duration duration, {bool trailing = false}) Stream<T>
Reduces the rate that events are emitted to at most once per duration.