Event struct passed to hooks during execution.
This provides a uniform interface for hooks across all node types, eliminating the need for workflow access during the execute phase.
Fields
:timing-:beforeor:afterindicating when the hook is running:node- The node struct being executed (Step, Condition, etc.):node_hash- Hash of the node for quick identification:input_fact- The input fact triggering this execution:result- For after hooks: the result of execution (Fact, boolean, etc.)
Example
# New-style hook (arity-2, workflow-free)
fn %HookEvent{timing: :before, node: step}, ctx ->
Logger.info("Executing step #{step.name}")
:ok
end
# Hook returning an apply_fn for workflow modifications
fn %HookEvent{timing: :after, result: fact}, _ctx ->
{:apply, fn workflow ->
Workflow.add(workflow, some_step, to: fact)
end}
end
Summary
Types
@type t() :: %Runic.Workflow.HookEvent{ input_fact: Runic.Workflow.Fact.t(), node: struct(), node_hash: integer(), result: term() | nil, timing: timing() }
@type timing() :: :before | :after
Functions
@spec after_exec(struct(), Runic.Workflow.Fact.t(), term()) :: t()
Creates an after-hook event with the execution result.
@spec before( struct(), Runic.Workflow.Fact.t() ) :: t()
Creates a before-hook event.