CreateTask | R Documentation |
Create a long-running task, on Linux executed in a forked process, on Windows in the same
session.
CreateTask(expr, args = NULL, timeout = 1000L)
expr |
Expression to be executed. Required. |
args |
List object with arguments to be passed to |
timeout |
Number of milliseconds between consecutive checks of the task. Optional. Default = 1000L |
The return value is a promise-like object with three methods:
- completed(): FALSE initially, then TRUE if the task succeeds, fails, or is cancelled. Reactive,
so when the state changes any reactive readers will invalidate.
- result(): Use this to get the return value. While execution is in progress, performs a
req(FALSE). If task succeeded, returns the return value. If failed, throws error. Reactive, so
when the state changes any reactive readers will invalidate.
- cancel(): Call this to prematurely terminate the task.
Closure
## Not run:
task <- CreateTask({
Sys.sleep(5)
cars[sample(nrow(cars), 10),]
})
shiny::isolate(task$result())
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.