replay_bloc library

An extension to the bloc state management library which adds support for undo and redo.

Get started at bloclibrary.dev 🚀

Classes

Bloc<Event, State>
Takes a Stream of Events as input and transforms them into a Stream of States as output.
BlocBase<State>
An interface for the core functionality implemented by both Bloc and Cubit.
BlocEventSink<Event extends Object?>
An ErrorSink that supports adding events.
BlocObserver
An interface for observing the behavior of Bloc instances.
BlocOverrides
This class facilitates overriding BlocObserver and EventTransformer. It should be extended by another class in client code with overrides that construct a custom implementation. The implementation in this class defaults to the base blocObserver and eventTransformer implementation. For example:
Change<State>
A Change represents the change from one State to another. A Change consists of the currentState and nextState.
Closable
An object that must be closed when no longer in use.
Cubit<State>
A Cubit is similar to Bloc but has no notion of events and relies on methods to emit new states.
Emittable<State extends Object?>
An object that can emit new states.
Emitter<State>
An Emitter is a class which is capable of emitting new states.
ErrorSink
A generic destination for errors.
ReplayBloc<Event extends ReplayEvent, State>
A specialized Bloc which supports undo and redo operations.
ReplayCubit<State>
A specialized Cubit which supports undo and redo operations.
ReplayEvent
Base event class for all ReplayBloc events.
StateStreamable<State>
A Streamable that provides synchronous access to the current state.
StateStreamableSource<State>
A StateStreamable that must be closed when no longer in use.
Streamable<State extends Object?>
An object that provides access to a stream of states over time.
Transition<Event, State>
A Transition is the change from one state to another. Consists of the currentState, an event, and the nextState.

Mixins

ReplayBlocMixin<Event extends ReplayEvent, State>
A mixin which enables undo and redo operations for Bloc classes.
ReplayCubitMixin<State>
A mixin which enables undo and redo operations for Cubit classes.

Typedefs

EventHandler<Event, State> = FutureOr<void> Function(Event event, Emitter<State> emit)
An event handler is responsible for reacting to an incoming Event and can emit zero or more states via the Emitter.
EventMapper<Event> = Stream<Event> Function(Event event)
Signature for a function which converts an incoming event into an outbound stream of events. Used when defining custom EventTransformers.
EventTransformer<Event> = Stream<Event> Function(Stream<Event> events, EventMapper<Event> mapper)
Used to change how events are processed. By default events are processed concurrently.