| set_timeout | R Documentation |
Run a function later (set_timeout()) or repeatedly
(set_interval()). Timers are part of the event loop: callbacks run
between events, never concurrently, and never block the interface.
Widgets have their own widget$set_timeout() / widget$set_interval(),
whose timers are cancelled when the widget is removed.
set_timeout(delay, callback, app = current_app())
set_interval(interval, callback, app = current_app())
delay, interval |
Seconds. |
callback |
|
app |
The app; defaults to the running app. |
A Timer; call $cancel() to stop it.
clock <- app(label("", id = "clock"), bind("q", "quit"))
clock$set_interval(1, function(app) {
app$query_one("#clock")$update(format(Sys.time(), "%H:%M:%S"))
})
if (interactive()) run(clock)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.