Takes an Event and triggers mapEventToState.
Dispatch may be called from the presentation layer or from within the Bloc.
Dispatch notifies the Bloc of a new Event.
If dispose has already been called, any subsequent calls to dispatch will
be delegated to the onError method which can be overriden at the Bloc
as well as the BlocDelegate level.
Closes the Event and StateStreams.
This method should be called when a Bloc is no longer needed.
Once dispose is called, events that are dispatched will not be
processed and will result in an error being passed to onError.
In addition, if dispose is called while Events are still being processed,
any States yielded after are ignored and will not result in a Transition.
Must be implemented when a class extends Bloc.
Takes the incoming event as the argument.
mapEventToState is called whenever an Event is dispatched by the presentation layer.
mapEventToState must convert that Event into a new State
and return the new State in the form of a Stream which is consumed by the presentation layer.
Called whenever an Exception is thrown within mapEventToState.
By default all exceptions will be ignored and Bloc functionality will be unaffected.
The stacktrace argument may be null if the state stream received an error without a StackTrace.
A great spot to handle exceptions at the individual Bloc level.
Called whenever a Transition occurs with the given Transition.
A Transition occurs when a new Event is dispatched and mapEventToState executed.
onTransition is called before a Bloc's State has been updated.
A great spot to add logging/analytics at the individual Bloc level.
Transforms the Stream<Event> along with a next function into a Stream<State>.
Events that should be processed by mapEventToState need to be passed to next.
By default asyncExpand is used to ensure all events are processed in the order
in which they are received. You can override transformEvents for advanced usage
in order to manipulate the frequency and specificity with which mapEventToState
is called as well as which events are processed. [...]
Transforms the Stream<State> into a new Stream<State>.
By default transformStates returns the incoming Stream<State>.
You can override transformStates for advanced usage
in order to manipulate the frequency and specificity at which transitions (state changes)