GdlrCommandHandler

Inherits: RefCounted < Object

Base class for command handlers.

Description

A handler runs one command type. Register it as the core of the command pipeline:

class_name AddPointsHandler
extends GdlrCommandHandler

func run(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context) -> Variant:
    var command: AddPointsCommand = envelope.command
    return CapGdlrCommandHandlers.LocalOutput.new([{"points": command.amount}], [])

# In a module:
handlers.set_core(AddPointsCommand, AddPointsHandler.new().run)

Tutorials

Methods


Method Descriptions

Variant run(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context) abstract 🔗

Runs the command in envelope and returns the handler output. The bundled command bus expects a CapGdlrCommandHandlers.LocalOutput. The method can await.