throttle<Event> function
Null safety
Emits an duration
, then repeats this process.
If leading
is true, then the first event in each window is emitted.
If trailing
is true, then the last event is emitted instead.
Example
on<ExampleEvent>(
_handler,
transformer: throttle(const Duration(seconds: 5))
);
Implementation
EventTransformer<Event> throttle<Event>(
Duration duration, {
bool trailing = false,
bool leading = true,
}) =>
(events, mapper) => events
.throttleTime(
duration,
trailing: trailing,
leading: leading,
)
.switchMap(mapper);