Channels
SBCanvas.channel(name) creates or joins a named pub/sub channel for widget-to-widget communication. Any widget can publish data, and any widget subscribed to that channel receives it.
Creating a Channel
score, timer_state, combo).
Publishing
Subscribing
Unsubscribing
Last Value
Access the most recent published value without subscribing:Example: Timer + Alert Coordination
Timer widget publishes countdown state:Example: Shared Theme
Settings widget publishes theme changes:API Reference
| Method | Returns | Description |
|---|---|---|
SBCanvas.channel(name) | WidgetChannel | Create or join a named channel |
ch.publish(data) | void | Send data to all subscribers |
ch.subscribe(fn) | void | Receive publishes (+ lastValue on join) |
ch.unsubscribe(fn) | void | Stop receiving |
ch.lastValue | any | Most recent published value |