Вы можете сделать эту функцию invalidateLater
. Вот пример кода:
library(shiny)
library(shinydashboard)
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
infoBoxOutput("ibox"),
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output, session){
val <- reactiveVal(0)
output$ibox <- renderInfoBox({
infoBox(
"Number",
val(),
icon = icon("credit-card")
)
})
observe({
invalidateLater(100, session)
isolate({
# It will count till 5000 because of this condition
if(val() < 5000) {
newVal <- val()+1
val(newVal)
}
})
})
}
shinyApp(ui, server)
Надеюсь, это поможет!