How can R(Shiny) perform multiple tasks at the same time? For example have a "clock" or timer in your UI which keeps on ticking while having an another "ObserveEvent" trigger/calculation running?
See the following example in Shiny below. When you press "click", the clock freezes since R starts focussing on the for loop.
ui <- fluidPage(
h2(textOutput("currentTime")),
actionButton("click","click")
)
server <- function(input, output, session) {
output$currentTime <- renderText({
invalidateLater(1000, session)
paste("The current time is", Sys.time())
})
observeEvent(input$click,{
showNotification("Computation started!", type = "error")
#Sys.sleep(2)
for(i in 1:(8*10^7)) 1 + 1
showNotification("Computation finished!", type = "error")
})
}
# Create Shiny app ----
shinyApp(ui, server)