Mediator class
An implementation for the architectural mediator pattern, with CQRS support.
void main() async {
// Create a new mediator, this should only be needed once per your application.
Mediator mediator = Mediator();
// Register the command handler for its command type.
// This will hopefully be code-generated later on.
mediator.registerCommand(GetAsStringCommandHandler());
// Create and run your command.
String result = await mediator.runCommand(GetAsStringCommand(123));
print(result);
}
Constructors
- Mediator()
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
-
registerCommand<
TCommand extends ICommand< (TResult> , TResult>ICommandHandler< TCommand, TResult> handler) → void - Registers an ICommandHandler for a custom ICommand type.
-
registerQuery<
TQuery extends IQuery< (TResult> , TResult>IQueryHandler< TQuery, TResult> handler) → void - Registers an IQueryHandler for a custom IQuery type.
-
runCommand<
TCommand extends ICommand< (TResult> , TResult>TCommand command) → Future< TResult> -
Executes the given
commandif a handler for it could be found, otherwise throws the StateError. -
runQuery<
TQuery extends IQuery< (TResult> , TResult>TQuery query) → Future< TResult> -
Executes the given
queryif a handler for it could be found, otherwise throws the StateError. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited