# `BB.Controller.PatternMatch`
[🔗](https://github.com/beam-bots/bb/blob/main/lib/bb/controller/pattern_match.ex#L5)

Controller that triggers an action when a message matches a predicate.

This is the base reactive controller implementation. Other reactive controllers
like `BB.Controller.Threshold` are convenience wrappers around this module.

## Options

- `:topic` - PubSub topic path to subscribe to (required)
- `:match` - Predicate function `fn msg -> boolean end` (required)
- `:action` - Action to trigger on match (required)
- `:cooldown_ms` - Minimum ms between triggers (default: 1000)

## Example

    controller :collision, {BB.Controller.PatternMatch,
      topic: [:sensor, :proximity],
      match: fn msg -> msg.payload.distance < 0.05 end,
      action: command(:disarm)
    }

---

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