# `Runic.Workflow.HookEvent`
[🔗](https://github.com/zblanco/runic/blob/main/lib/workflow/hook_event.ex#L1)

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` - `:before` or `:after` indicating 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

# `t`

```elixir
@type t() :: %Runic.Workflow.HookEvent{
  input_fact: Runic.Workflow.Fact.t(),
  node: struct(),
  node_hash: integer(),
  result: term() | nil,
  timing: timing()
}
```

# `timing`

```elixir
@type timing() :: :before | :after
```

# `after_exec`

```elixir
@spec after_exec(struct(), Runic.Workflow.Fact.t(), term()) :: t()
```

Creates an after-hook event with the execution result.

# `before`

```elixir
@spec before(
  struct(),
  Runic.Workflow.Fact.t()
) :: t()
```

Creates a before-hook event.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
