ApplyCommandRunner class final
A helper class used to set up and execute an action on a cell.
ApplyCommandRunner is a "builder" that gathers all the pieces needed for a command—the function, the arguments, and the "undo" logic—before sending it to the framework for execution.
In the framework's biological metaphor, this is the Signal Assembly phase. It prepares a nervous impulse with the correct intensity (data) and reflex (undo logic) before it is transmitted through the reactive graph.
Why it is used
- Readability: It allows you to chain methods together in a way that
reads like a sentence:
cell.command(setAge).arg(25).run(). - Step-by-Step Setup: It makes it easy to add complex parameters, like named arguments or "undo" logic, without dealing with messy nested records.
- Immediate Execution: It links the command directly to a cell, allowing you to run the action as soon as you finish building it.
How it works
- Initialization: You start with a cell and a function (via the DSL).
- Configuration: You call methods like args or undo to add details. These details are stored temporarily inside the runner.
- Execution: You call run to submit the command to the cell, or build if you just want the raw record to use later.
Technical Details
- Stateful Builder: Unlike the final command record, this class is mutable while it is being built. It is designed to be short-lived.
- Type Preservation: The run method uses a generic type
Rto ensure that the result you get back matches the type returned by your function.
See also:
- ApplyCommandDSL — The extension that creates this runner.
- ApplyCommand — The final record produced by this builder.
- Cell.apply — The method called when you trigger run.
Constructors
- ApplyCommandRunner(Cell cell, Function function)
-
Creates a builder for invoking
functiononcell.
Properties
Methods
-
arg(
Object? argument) → ApplyCommandRunner - Sets a single positional argument of the command.
-
args(
List< Object?> arguments) → ApplyCommandRunner - Sets the positional argument list of the command.
-
build(
) → ApplyCommand - Materializes the assembled command record.
-
named(
Map< Symbol, Object?> arguments) → ApplyCommandRunner - Sets the named argument map of the command.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run<
R> ({ApplyTransactionScope? tx}) → FutureOr< ApplyOutcome< R> > - Submits the assembled command to the bound cell and returns its auditable ApplyOutcome.
-
toString(
) → String -
A string representation of this object.
inherited
-
undo(
Function compensation, {List< Object?> ? args, Map<Symbol, Object?> ? named, Cell? cell}) → ApplyCommandRunner - Attaches a Reversal Blueprint to the command.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited