Goal
Run a Function whenever a specific state value changes, using astate trigger.
Steps
1. Enable the State module
iii-config.yaml
2. Register the Function
Thestate trigger fires whenever the watched scope/key pair changes. The handler receives an event with key, new_value, old_value, scope, and event_type properties.
- Node / TypeScript
- Python
- Rust
state-watcher.ts
3. Register the state trigger
Each state trigger watches a singlescope/key pair. To react to multiple keys, register a function and trigger for each.
- Node / TypeScript
- Python
- Rust
state-trigger.ts
Result
When any Function writes to the watchedscope/key pair via state::set or state::update, the Engine automatically invokes the registered handler with the new value.