Currently, I have a web client Shiny application that is run on a virtual server and allows users to access the app via a website if they are logged onto the company network. I want my application to update its data every 24 hours using invalidateLater(24*60*60*1000, session)
, however, since the databases are very large, I don't want this command running every time a user accesses the application, making the user have to wait 3-4 minutes before they get to use the app. Is there any way I can schedule an update for refreshing my data without having the app update (and wait) every time a new session starts?
Asked
Active
Viewed 267 times
0

Agrosel
- 489
- 3
- 15
-
remove the `session` argument. on app start `invalidateLater(24*60*60*1000)`. Also add a global assignment operator to the variable using `<<-` – Pork Chop Nov 19 '16 at 15:15
-
@PorkChop after checking out this answer and the answer from here [link](http://stackoverflow.com/questions/20333399/are-there-global-variables-in-r-shiny), I see the similarities from these two answers, but I'm still confused. My code is: `observe({invalidateLater(24*60*60*1000); shots = sqlFetch(sql_ch, "player_shots"); })` and `ggplot(data=shots, aes(x = x, y = y)) + geom_point()`. I guess I don't get where the global variable comes in. – Agrosel Nov 19 '16 at 17:26
-
Global assignment is useful if you do something like :`observe({invalidateLater(24*60*60*1000); shots <<- sqlFetch(sql_ch, "player_shots"); })` now you can use the `shots` variable anywhere inside your app, which will be visible to all the sessions. You can use `shots` as a variable and now a function – Pork Chop Nov 20 '16 at 14:08
-
@PorkChop thanks for commenting back, unfortunately the refresh is still happening at the start of these sessions every time, even when I remove the "session" parameter. Any other idea to why this is happening? Is there any way I can do a quicker refresh (like add on new data rather than reload the entire data set)? – Agrosel Nov 21 '16 at 16:41