Reputation: 7725
I have a flexdashboard that uses shiny. Here's a MRE repo and gist of the .Rmd
. When I put the app live on shinyapps.io, I realized that one user's actions could affect other users. I understand that this is a scoping issue, but I'm confused about how scoping works in Flexdashboard.
This page explains scoping for 'regular' shiny apps:
You might want some objects to be visible across all sessions. For example, if you have large data structures, or if you have utility functions that are not reactive (ones that don’t involve the input or output objects), then you can create these objects once and share them across all user sessions (within the same R process), by placing them in app.R , but outside of the server function definition.
In Flexdashboard, there is no app.R
file or server
function. How does scoping work in these types of shiny apps?
I have several eventReactive()
functions like this that get updated for User 2 when User 1 hits submit and triggers observeEvent(input$submit, {})
at the end of the file.
eventReactive(rv$run2, {
if (remote==1) {
master$df <- drop_read_csv("/dash/master.csv", stringsAsFactors = FALSE)
} else {
master$df <- read.csv("dash/master.csv", stringsAsFactors = FALSE)
}
}, ignoreNULL = TRUE)
I originally posted this to RStudio Community about 9 hours ago, but it did not generate many views (<20) or any discussion.
Upvotes: 3
Views: 192
Reputation: 7725
Moving rv <- reactiveValues()
out of the global
chunk did the trick.
Upvotes: 2