I have an R Shiny dashboard that has 2 observers that are set to refresh at specific times, One observer refreshes every 6 hours, the other every 2 mins. Both observers run a function that returns a reactive value. This works fine, however every 6 hours when the first observer is triggered it locks the dashboard and prevents the other observer from functioning. After some reading I know that I need to use futures and promises but am unable to implement anything that works as intended. How do I wrap the functions in each observer into respective futures that would prevent blocking?
values <- reactiveValues()
observe({
# Re-execute this reactive expression every 2 mins
invalidateLater(120000, session)
values$twominresult <- twoMinFunction()
})
observe({
# Re-execute this reactive expression every 6 hours
invalidateLater(21600000, session)
values$sixhourresult <- sixhourfunction()
})
sixhourfunction()
is a long-running function. it will block all other observers in this particular session even if you use futures. The only time this is useful is for multiple sessions running in parallel. rstudio.github.io/promises/articles/shiny.html – Hypogeal