Hi there,
I am using bloc to send events throughout my app after reading RFID tags from a hardware device. I'm not sure why, but it seems it takes an incredibly long time from the event dispatch, till the maptostate function is called.
the delayed dispatch events cause a problem in my app, because they arrive in my bloc, after the state of the application has already changed.
Is it possible to clear all events that are in the "queue" of a bloc from the view?
ok I think I understand now, in mapEventToState, the end of the stream needs to be reached, for the next mapEventToState to be triggered, right?
Hi @Freundschaft 馃憢
Thanks for opening an issue!
Yes, by default, a bloc will only start processing the next event once the current event has been processed. You can change this behavior by overriding transformEvents like so:
@override
Stream<State> transformEvents(events, next) {
return (events as Observable<Event>).switchMap(next);
}
This will tell the bloc to stop processing old events whenever a new event is received. Hope that helps 馃憤
perfect, thanks!
Most helpful comment
perfect, thanks!