sampleTime method

Stream<T> sampleTime(
  1. Duration duration
)

Emits the most recently emitted item (if any) emitted by the source Stream since the previous emission within the recurring time span, defined by duration

Example

Stream.fromIterable([1, 2, 3])
  .sampleTime(Duration(seconds: 1))
  .listen(print); // prints 3

Implementation

Stream<T> sampleTime(Duration duration) =>
    sample(Stream<void>.periodic(duration));