Timers
Use SBCanvas timers instead of rawsetTimeout/setInterval. They’re tracked per widget and automatically cleaned up when the widget unloads, preventing dead DOM callbacks and memory leaks.
setTimeout
setInterval
clearTimer
Cancel either a timeout or interval:Why Not Raw setTimeout?
Example: Auto-Hide Alert
Example: Live Clock
Example: Polling External Data
API Reference
| Method | Returns | Description |
|---|---|---|
SBCanvas.setTimeout(fn, ms) | number | Schedule a one-shot callback |
SBCanvas.setInterval(fn, ms) | number | Schedule a repeating callback |
SBCanvas.clearTimer(id) | void | Cancel a timeout or interval |