Skip to content

Conversation

@jimsynz
Copy link
Contributor

@jimsynz jimsynz commented Jan 5, 2026

Summary

  • Add off-the-shelf controllers that monitor PubSub messages and trigger actions when conditions are met
  • BB.Controller.PatternMatch - triggers when messages match a predicate function
  • BB.Controller.Threshold - convenience wrapper for numeric field threshold monitoring
  • BB.Controller.Action - action system with command/1,2 and handle_event/1 builders
  • Add module groups to ex_doc for better documentation organisation

Example Usage

defmodule MyRobot do
  use BB

  # Disarm if servo current exceeds limit
  controller :over_current, {BB.Controller.Threshold,
    topic: [:sensor, :servo_status],
    field: :current,
    max: 1.21,
    action: command(:disarm)
  }

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

Test plan

  • Unit tests for BB.Controller.Action (7 tests)
  • Unit tests for BB.Controller.PatternMatch (7 tests)
  • Unit tests for BB.Controller.Threshold (10 tests)
  • All existing tests pass
  • mix check --no-retry passes

Add off-the-shelf controllers that monitor PubSub messages and trigger
actions when conditions are met:

- `BB.Controller.PatternMatch` - triggers when messages match a predicate
- `BB.Controller.Threshold` - triggers when numeric fields exceed bounds
- `BB.Controller.Action` - action system with `command/1,2` and `handle_event/1`

Also adds module groups to ex_doc for better documentation organisation.
@jimsynz jimsynz force-pushed the feature/reactive-controllers branch from 9474b87 to 911d1c3 Compare January 5, 2026 07:05
@jimsynz jimsynz merged commit ac59ed5 into main Jan 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants