Timer.cancel
luastra/timerTimer.cancel(id: string): RequestId
Cancels the pending timer identified by the stable string ID and returns a request acknowledgement. A successfully cancelled timer will not later emit its timer event.
Before you use it
Add luastra/timer to this module's dependencies in luastra.json, then import it with require("luastra/timer"). Declare timer.control in luastra.json and implement app.handle for timer events. The maximum delay is 60,000 ms.
How it fits
start, restart, and cancel return an acknowledgement RequestId, but timer.control completions are intentionally not delivered to app.resolve. A one-shot expiry arrives later as app.handle("timer", timerId, value).
When to use it
Use Timer.cancel when leaving the owning screen, completing work early, or replacing an automatic transition with a user decision. Cancellation should be safe even if application state has already moved on.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| id | string | Stable string ID of the pending logical timer to cancel. |
Returns
RequestId — an opaque acknowledgement token for the timer control request. Timer acknowledgements do not enter app.resolve; an uncancelled expiry arrives through app.handle.
What happens next
The requested timer operation is acknowledged; an uncancelled start or restart later emits one timer event.
Failures and fixes
Missing timer.control, an invalid lowercase timer id, a delay outside 0..60000, or an oversized value fails before a timer event is scheduled. Treat late events as stale if the owning state has already changed.
Availability
Public-source alpha API in 0.5.0-alpha; exact background timing remains host-dependent.
Focused example
local Timer = require("luastra/timer")
Timer.cancel("game/next-card")