How do you set the priority in which reactive()
calculations are performed in Shiny? For example, there is a priority
option in observe()
, quoting the help file
priority
An integer or numeric that controls the priority with which this observer
should be executed. An observer with a given priority level will always execute
sooner than all observers with a lower priority level. Positive, negative,
and zero values are allowed.
I wish to apply this by having my Shiny dashboard display some summary statistics before writing these statistics to a logging database, here is an example
In server.R
retrieve data every hour
observe({
invalidateLater(3600000,session)
con <- dbConnect(PostgreSQL(), ...)
values$data = dbGetQuery(con, "select * from table;")
})
output$text = renderText({
temp = values$data
print(paste("the mean is", mean(temp)))
})
observe({
temp = values$data
dbWriteTable(con, paste0("Insert into table_means Values (", (mean(temp),");" ))
})
And in ui.R
I print the mean of the data.
I wish the rendering in the UI to occur before writing the values to my sql database
Here are some related questions:
R shiny Observe running Before loading of UI and this causes Null parameters