
Last chance! 50% off unlimited learning
Sale ends in
delay
if you want to wait a specific amount of time before
running code. This function can be used in combination with other shinyjs
functions, such as hiding or resetting an element in a few seconds, but it
can also be used with any code as long as it's used inside a Shiny app.delay(ms, expr)
useShinyjs
,
runExample
if (interactive()) {
shinyApp(
ui = fluidPage(
useShinyjs(),
p(id = "text", "This text will disappear after 3 seconds"),
actionButton("close", "Close the app in half a second")
),
server = function(input, output) {
delay(3000, hide("text"))
observeEvent(input$close, {
delay(500, stopApp())
})
}
)
}
Run the code above in your browser using DataLab