throttleTime method

Stream<T> throttleTime(
  1. Duration duration, {
  2. bool trailing = false,
  3. bool leading = true,
})

Emits a value from the source Stream, then ignores subsequent source values for a duration, then repeats this process.

If leading is true, then the first item in each window is emitted. If trailing is true, then the last item is emitted instead.

Example

Stream.fromIterable([1, 2, 3])
  .throttleTime(Duration(seconds: 1));

Implementation

Stream<T> throttleTime(Duration duration,
        {bool trailing = false, bool leading = true}) =>
    ThrottleStreamTransformer<T>(
      (_) => TimerStream<bool>(true, duration),
      trailing: trailing,
      leading: leading,
    ).bind(this);