CapGdlrCommandHandlers¶
Inherits: GdlrCapability < RefCounted < Object
Capability that registers and runs local command handlers.
Description¶
Each command class gets one pipeline. Register the handler as the core of that pipeline and add middleware around it:
var handlers: CapGdlrCommandHandlers
func register() -> void:
handlers.set_core(AddPointsCommand, AddPointsHandler.new().run)
handlers.use(AddPointsCommand, LogMiddleware.new())
Godular ships a service for this capability at res://addons/godular/built_ins/services/command_handlers.svc.gd. See GdlrCommandPipeline for the callback signatures and the run order.
Tutorials¶
Methods¶
run(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context) abstract |
|
void |
|
void |
use_before(command: GDScript, before: Callable) abstract |
void |
use_around(command: GDScript, around: Callable) abstract |
void |
|
void |
use(command: GDScript, middleware: GdlrCommandMiddleware, priority: int = 0) abstract |
void |
remove_by_callback(command: GDScript, callback: Callable) abstract |
void |
use_global_around(around: Callable, priority: int = 0, should_run: Callable = Callable()) abstract |
void |
remove_global_by_callback(callback: Callable) abstract |
Method Descriptions¶
Variant run(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context) abstract 🔗
Runs the command in envelope through the pipeline of its class and returns the result of the pipeline.
void set_core(command: GDScript, core: Callable) abstract 🔗
Sets the handler callable for command. See GdlrCommandHandler.
void use_before(command: GDScript, before: Callable) abstract 🔗
Adds a callback that runs before the handler of command.
void use_around(command: GDScript, around: Callable) abstract 🔗
Adds a callback that wraps the handler of command.
void use_after(command: GDScript, after: Callable) abstract 🔗
Adds a callback that runs after the handler of command.
void use(command: GDScript, middleware: GdlrCommandMiddleware, priority: int = 0) abstract 🔗
Registers every callback that middleware implements for command. See GdlrCommandMiddleware.
void remove_by_callback(command: GDScript, callback: Callable) abstract 🔗
Removes every callback of command that uses callback.
void use_global_around(around: Callable, priority: int = 0, should_run: Callable = Callable()) abstract 🔗
Adds an around callback to the pipelines of every command, including commands registered later.
void remove_global_by_callback(callback: Callable) abstract 🔗
Removes a callback added with use_global_around() from every pipeline.