StateMediator class
The StateMediator is a class that stores the configuration for the mediator and provides a way to register handlers for commands. All handlers must be registered before using the Mediator to ensure that the commands are handled correctly.
The errorHandler is a function that will be called if an error occurs while handling a command. By default, the error handler will do nothing.
The handlers is a map that stores the registered handlers for commands.
The key is the type of the command and the value is the handler.
The registerHandler method is used to register a new handler for a command.
The getHandler method is used by the Mediator to get a handler for a command. It will throw an error if no handler is registered for the command type.
Constructors
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- errorHandler ↔ Result Function(Object e, StackTrace stackTrace)
-
getter/setter pair
Static Methods
-
getHandler<
C extends Command> (C command) → CommandHandler< Command, dynamic> - The method to get a handler for a command. It will throw an error if no handler is registered for the command type.
-
registerHandler<
C extends Command> (CommandHandler< Command, dynamic> handler) → void - The method to register a new handler for a command. The handler will be stored in the map with the command type as the key.