debounce<Event> function Null safety

EventTransformer<Event> debounce<Event>(
  1. Duration duration
)

Event transformer that will only emit items from the source sequence whenever the time span defined by duration passes, without the source sequence emitting another item.

This time span start after the last debounced event was emitted.

debounce filters out items obtained events that are rapidly followed by another emitted event.

Interactive marble diagram

Example

on<ExampleEvent>(
  _handleEvent,
  transformer: debounce(const Duration(seconds: 1)),
);

Implementation

EventTransformer<Event> debounce<Event>(Duration duration) =>
    (events, mapper) => events.debounceTime(duration).switchMap(mapper);