I'm not sure about the state of things mid 2021, but as of 2025, the answer of @mnist is incorrect. It is very well possible to set an input in a child module using shiny::testServer()
:
testServer(summaryServer, args = list(var = reactiveVal(1:10)), {
cat("var active?", d_act(),"\n")
range <- session$makeScope("range")
range$setInputs(go = 1)
cat("var active?", d_act(), "\n")
})
should do exactly what was asked for.
There is a minor issue with the provided example code though: rangeServer ()
should return var
, e.g. as
rangeServer = function(id, var){
moduleServer(id, function(input, output, session){
# when button gets clicked
eventReactive(input$go,{
range(var(), na.rm = TRUE)
}, ignoreInit = TRUE, ignoreNULL = TRUE)
})
var
}
given that in summaryServer()
, we assign the result of rangeServer()
to range_val
.