debounce<Event> function
Null safety
- 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.
Example
on<ExampleEvent>(
_handleEvent,
transformer: debounce(const Duration(seconds: 1)),
);
Implementation
EventTransformer<Event> debounce<Event>(Duration duration) =>
(events, mapper) => events.debounceTime(duration).switchMap(mapper);