I could not get the syntax correct to inputs of an embedded module:
library(shiny)
myModuleServer <- function(id, multiplier = 2, prefix = "I am ") {
moduleServer(id, function(input, output, session) {
myreactive <- reactive({
input$x * multiplier
})
output$txt <- renderText({
paste0(prefix, myreactive())
})
})
}
server <- function(input, output, session) {
x <- reactive(input$a * input$b)
ms = myModuleServer("ms")
}
testServer(server, {
session$setInputs(a = 2, b = 3)
stopifnot(x() == 6)
# How to set inputs of embedded module?
# Something like this, but obviously it does not work
# session$setInputs(NS("ms")$x = 1)
# stopifnot(NS("ms")$myreactive() == 2)
})