Skip to content
docsv0.1.0

InteractionResult

The outcome of {@see \Milpa\Live\Contracts\Component\ComponentDefinitionInterface::handle()} processing an {@see InteractionRequest}. `$state` is always the component's new state — even an action that ultimately failed MUST return the (possibly unchanged) state rather than omitting it, since callers do not treat a non-empty `$errors` as "no state to persist".

InteractionResult::__construct()

public function __construct(Milpa\Live\ValueObjects\StateSnapshot $state, ?string $html = null, array $effects = [], array $errors = [], array $meta = []):

Parameters

Parameters of __construct()
NameTypeDescription
$stateStateSnapshotThe component's state after the action was applied.
$html(string | null)Pre-rendered HTML for this result, when the component renders itself rather than leaving re-rendering to a {@see \Milpa\Live\Contracts\Rendering\ComponentRendererInterface}.
$effectsarray<int, array<string, mixed>>Client-side side effects to perform (e.g. `['type' => 'persist']`); shape is action/effect-type defined, not standardized here.
$errorsarray<string, mixed>Field/reason => human-readable message, for an action the component recognized but rejected or partially failed.
$metaarray<string, mixed>Caller-defined extra context beyond the fields above.