79426474

Date: 2025-02-10 08:35:28
Score: 0.5
Natty:
Report link

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.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @mnist
  • Low reputation (0.5):
Posted by: nbenn