throttleDroppable<E> function
Creates an EventTransformer
that throttles incoming events and processes them with droppable
.
This ensures that events are processed at most once in the given duration
, and
new events arriving during that window are dropped.
Example usage:
on<MyEvent>(
_onMyEvent,
transformer: throttleDroppable(throttleDuration),
);
Implementation
EventTransformer<E> throttleDroppable<E>(Duration duration) {
return (events, mapper) {
return droppable<E>().call(events.throttle(duration), mapper);
};
}