Description Usage Arguments Value Examples
This is useful when using helper functions in the long running function.
1 | is.fmError(x)
|
x |
object to test |
logical
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | if (interactive()) {
library(shiny)
plan(fmParallelStrategy())
helper <- function(n){
if (n < 0) return(fmError("n must be >= 0"))
log(n)
}
longFun <- function(task, n){
x <- helper(n)
if (is.fmError(x)) return(x)
x^2
}
shinyApp(
ui = basicPage(
uiOutput("button"),
numericInput("n", "n", -3, -5, 5),
textOutput("result")
),
server = function(input, output, session){
fm <- FutureManager$new(input, session)
output$button <- renderUI(fmRunButton("run", fm))
Res <- reactiveVal()
Args <- reactive(list(n = input$n))
fm$registerRunObserver("run", NULL, Res, longFun, Args, progress = FALSE)
output$result <- renderText({
res <- Res()
fmValidate(res)
fmGetValue(res)
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.