How to trigger data refresh automatically in R shiny dashboard

Viewed 102

I have the below function to read data from RDS file.

# Function to get updated data
updateData <- function(forceclick = FALSE){

  update_data <<- readRDS(path, "update_data.rds")
  
}

And, there is an action button in the UI to update data when it is triggered.

##On the UI side action button to refresh data load
actionButton("update_button",
             "Data refresh")

###data refresh code on server side
observeEvent(input$update_button, {

  updateData(forceclick = TRUE)
  
})

Here the data is refreshed when the actionButton ´input$update_button´ is triggered.

Here i am supposed to do manual refresh using the action button as shown in the sample code or manually scale down the pods and scale up.

How could the data upload be automated for eg: every morning without the need to trigger the actionButton ´input$update_button´?

Can ´invalidateLater´ be used for observeEvent like below?

###data refresh code on server side
  observeEvent(input$update_button, {
    invalidateLater(1000000,session)
    updateData(forceclick = FALSE)
    
  })

or could it be solved if the updateData() is executed periodically at set time which reads the .rds file?

0 Answers
Related