Interface ICommandBus
- Routes Commands to exactly one handler per command type.
- Designed for UI/Node -> Controller command flow (single receiver).
- Provides IDisposable registration token for clean unregistration.
Assembly: Glitch9.dll
Syntax
public interface ICommandBus
Methods
|
Edit this page
View Source
Dispatch<TCommand>(TCommand)
- Dispatches a command to its handler.
- Throws if no handler is registered for the command type.
Declaration
void Dispatch<TCommand>(TCommand command) where TCommand : ICommand
Parameters
| Type |
Name |
Description |
| TCommand |
command |
|
Type Parameters
| Name |
Description |
| TCommand |
|
|
Edit this page
View Source
IsRegistered<TCommand>()
- Returns whether a handler is registered for the command type.
Declaration
bool IsRegistered<TCommand>() where TCommand : ICommand
Returns
Type Parameters
| Name |
Description |
| TCommand |
|
|
Edit this page
View Source
Register<TCommand>(ICommandHandler<TCommand>)
Declaration
IDisposable Register<TCommand>(ICommandHandler<TCommand> handler) where TCommand : ICommand
Parameters
Returns
Type Parameters
| Name |
Description |
| TCommand |
|
|
Edit this page
View Source
Register<TCommand>(Action<TCommand>)
- Registers a handler for the given command type.
- Throws if a handler already exists for the command type.
Declaration
IDisposable Register<TCommand>(Action<TCommand> handler) where TCommand : ICommand
Parameters
| Type |
Name |
Description |
| Action<TCommand> |
handler |
|
Returns
Type Parameters
| Name |
Description |
| TCommand |
|
|
Edit this page
View Source
TryDispatch<TCommand>(TCommand)
- Dispatches a command if a handler is registered.
- Returns false if no handler is registered.
Declaration
bool TryDispatch<TCommand>(TCommand command) where TCommand : ICommand
Parameters
| Type |
Name |
Description |
| TCommand |
command |
|
Returns
Type Parameters
| Name |
Description |
| TCommand |
|
|
Edit this page
View Source
Unregister<TCommand>(ICommandHandler<TCommand>)
Declaration
void Unregister<TCommand>(ICommandHandler<TCommand> handler) where TCommand : ICommand
Parameters
Type Parameters
| Name |
Description |
| TCommand |
|
|
Edit this page
View Source
Unregister<TCommand>(Action<TCommand>)
- Unregisters a handler for the given command type (if present).
Declaration
void Unregister<TCommand>(Action<TCommand> handler) where TCommand : ICommand
Parameters
| Type |
Name |
Description |
| Action<TCommand> |
handler |
|
Type Parameters
| Name |
Description |
| TCommand |
|
Extension Methods