restartable<Event> function Null safety

EventTransformer<Event> restartable<Event>()

Process only one event by cancelling any pending events and processing the new event immediately.

Avoid using restartable if you expect an event to have immediate results -- it should only be used with asynchronous APIs.

Note: there is no event handler overlap and any currently running tasks will be aborted if a new event is added before a prior one completes.

Implementation

EventTransformer<Event> restartable<Event>() {
  return (events, mapper) => events.switchMap(mapper);
}