MVUProcessor<Model, Msg> class abstract

Detached MVU processor that can be used to dispatch messages from anywhere. It can be created from functions or subclassed. This is useful when you want to dispatch messages from outside the view. The processor can also be used with dependency injection to create a singleton.

Constructors

MVUProcessor()
MVUProcessor.fromFunctions({required (Model, Cmd<Msg>) init(), required (Model, Cmd<Msg>) update(Msg, Model), Subscription<Model, Msg>? subscriptions, bool modelEquality(Model, Model)?})
Create a new MVUProcessor from functions instead of subclassing.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispatch(Msg msg) → void
Dispatch a message to the processor.
dispose() → void
Stop listening for new messages and cancel all active subscriptions
init() → (Model, Cmd<Msg>)
Creates an initial model and a list of commands.
modelEquality(Model previousModel, Model nextModel) bool
Defines the function to use to compare models to prevent unnecessary updates.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subscribe(void handler(Model model, Dispatch<Msg> dispatch)) StreamSubscription<Model>
Subscribe to changes in the model. This can be used to update the UI.
subscriptions(Model model) Subs<Msg>
Creates a list of subscriptions using the model.
toString() String
A string representation of this object.
inherited
update(Msg msg, Model model) → (Model, Cmd<Msg>)
Creates an updated model and a list of commands from a message and the current model.
useModel<T>(T handler(Model model, Dispatch<Msg> dispatch)) Future<T>
Use the model, after all current messages are processed, and dispatch function. Can be used to return values and dispatch new messages depending on the current model.
useModelSync<T>(T handler(Model model, Dispatch<Msg> dispatch)) → T
Use the current model at the call instant and dispatch function. Can be used to return values and dispatch new messages depending on the model. If messages were dispatched right before calling this function, there is a good chance that the model will be outdated.

Operators

operator ==(Object other) bool
The equality operator.
inherited