I'm trying to make an observeEvent react to changes in a reactiveValues object. Here, the reactiveValues "test_vals" contains the values of the 2 numeric inputs shown below.
Expected behaviour: observeEvent(test_vals,...) should execute whenever there is a change to either of the 2 numeric inputs, and "test_vals changed" should get printed to the console.
Actual behaviour: It doesn't execute at all.
Reprex below.
library(shiny)
ui <- fluidPage(
numericInput("x", "x", 5),
numericInput("y", "y", 10)
)
server <- function(input, output, session) {
test_vals <- reactiveValues(
x = reactive(input$x),
y = reactive(input$y)
)
observeEvent(test_vals, {
print("test_vals changed")
})
}
shinyApp(ui, server)
reactiveValues
? Can you just useobserveEvent(c(input$x, input$y), {print("test_vals changed")})
?observeEvent
is in another module, then I think the only way to handle it is to store the inputs in areactiveValues
, and then return that from the module. Do you know how to deal with a case like that?