Module: cwc.timer
Low-level API to create a timer.
| data |
table |
user data table |
Read only
|
| started |
boolean |
Whether the timer is currently running or not.
|
|
| timeout |
boolean |
The timer timeout value in seconds.
|
|
-
🔗
cwc.timer.new (timeout, callback, options, data)
-
Create a new timer.
Parameters:
| timeout |
|
number |
Timeout in seconds |
Not applicable |
| callback |
|
function |
Callback when the timer ends |
Not applicable |
| options |
Optional |
table |
Additional settings |
Undefined |
| autostart |
Optional |
boolean |
Immediately start the timer
countdown |
true |
| call_now |
Optional |
boolean |
Immediately call the callback
function |
false |
| single_shot |
Optional |
boolean |
Run only once then stop |
false |
| one_shot |
Optional |
boolean |
Run only once then destroy |
false |
| data |
Optional |
any |
Userdata callback argument. |
nil |
-
🔗
cwc.timer.delayed_call (callback, data)
-
Call the given function at the end of wayland event loop.
Parameters:
| callback |
|
function |
|
Not applicable |
| data |
Optional |
any |
Userdata callback argument |
nil |
-
🔗
started
boolean
-
Whether the timer is currently running or not.
Constraints:
|
Default value
|
: false |
|
Valid values
|
: true or false. |
-
🔗
timeout
boolean
-
The timer timeout value in seconds.
Constraints:
|
Default value
|
: false |
|
Valid values
|
: true or false. |
-
🔗
:start ()
-
Start the timer.
-
🔗
:stop ()
-
Stop the timer.
-
🔗
:again ()
-
Restart the timer.
Equivalent to stopping the timer and then starting it again.
-
🔗
:destroy ()
-
Destroy the timer, invalidate the object and freeing it from memory.