I have a shiny app in which more than one reactive component uses the same result from a function that is slow to calculate. To avoid calculating the slow function more tha
say you have defined a reactive variable table_updated
so you can increment it by one each time the slow function is done. Other values/plots will only need to observe table_updated
.
Actually the actionButton(see description section) does the same thing, every time it gets clicked, its value is incremented by 1.
values <- reactiveValues(table_updated = 0)
slow.func = function(my.dt, x) {
# do stuff
values$table_updated <- values$table_updated + 1
}
output$result2 = renderText({
values$table_updated
paste('Final value =', values$dt[100,]$v2)
})