Why aren't my reactive values initialised in the server function unique to each session?

I'm deploying my app to shinyapps and I'm noticing some strange behaviour when I have multiple windows open. I have rendered a datatable and when I update the filters on a window, my table only updates on the last window that was opened.

I have moved my reactive values to be loaded in the server function after reading the scoping documentation.

app.R

source("helpers/load_data.R")

server <- function(input, output, session) {

source("helpers/load_session_data.R")

observeEvent(input$get_filtered_data, {
    # UpdateTable function takes my table_csv and filters by the date, and updates the riskData reactive value
    UpdateTable(table, input$date)
}

UpdateTable <- function(table, date) {
#... filter stuff
riskData$data <- filtered_table
}
}

load_session_data.R

#table is a data.frame loaded globally outside of the ui and server functions.
riskData <- reactiveValues(data = table_csv) 

I thought that loading my reactive values in the server function meant that each session would have it's own reactive values? I want to be able to filter a table independently in different sessions.

Any chance you can create a reproducible example for others to run on their own machine? This will make it easier for others to tinker with a solution.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.