'How does Bloc's EventTransformer works?

I really don't understand how the EventTransformer works in bloc library. I need to know this info because I may need to implement a custom transformer in my apps. For example, this custom transformer

EventTransformer<RegistrationEvent> debounceRestartable<RegistrationEvent>(
    Duration duration,
  ) {
    return (events, mapper) => restartable<RegistrationEvent>()
        .call(events.debounceTime(duration), mapper);
  }

makes RegistrationEvents restartable (i.e. "process only one event by cancelling any pending events and processing the new event immediately."), and this transformer also creates a "guard time" between events so that if two RegistrationEvents arrive in duration interval less than duration, only one will be processed.

But I don't understand from the documentation how is this code doing this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source