# `BB.Reactor.Middleware.Context`
[🔗](https://github.com/beam-bots/bb_reactor/blob/main/lib/bb/reactor/middleware/context.ex#L5)

Middleware that injects BB context into the reactor.

This middleware must be included in any reactor that uses BB steps. It creates
a `BB.Reactor.Context` and stores it in `context.private.bb`, making robot
information available to all steps.

## Usage

Add to your reactor's middleware:

```elixir
defmodule MyRobot.PickAndPlace do
  use Reactor, extensions: [BB.Reactor]

  # BB.Reactor extension automatically adds this middleware
  # ...
end
```

Or manually:

```elixir
defmodule MyReactor do
  use Reactor

  middlewares do
    middleware {BB.Reactor.Middleware.Context, robot: MyRobot}
  end
end
```

## Accessing Context in Steps

```elixir
def run(arguments, context, options) do
  bb = context.private.bb

  # Access robot module
  robot = bb.robot_module

  # Access static robot struct
  links = bb.robot.links

  # Check current state
  if bb.robot_state == :idle do
    # ...
  end
end
```

---

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