I have been studying the following question.
However, I am stuck on a variation of the problem:
I am trying to pass only certain values (vals) from the inputModule to the outputModule.
However, my inputModule also has an additional rendered output. This seems to be preventing the app from working.
I my real life app, the inputModule needs to pass data to a nested (outputmodule) and produces additional output and UI as well.
How can I restrict callModule or MyImProxy to only the vals and not pass output$mytext to my outputModule in the app server call?
Is is possible to have this code run while keeping the output$mytext
in the inputModule`?
Many thanks
library(shiny)
inputModuleUI <- function(id){
ns <- NS(id)
wellPanel(h3("Input Module"),
textInput(ns('text1'), "First text"),
textInput(ns('text2'), "Second text"),
textInput(ns('text3'), "Third text")
),
verbatimTextOutput(ns("mytext"))
}
inputModule <- function(input, output, session){
vals <- reactiveValues()
observe({vals$text1 <- input$text1})
observe({vals$text2 <- input$text2})
return(vals)
#I need this output to stay in the inputModule
output$mytext <- renderPrint({
paste(input$text3)
})
}
outputModuleUI <- function(id){
tagList(
inputModuleUI('IM'),
wellPanel(h3("Output Module"),
verbatimTextOutput(NS(id, "txt")))
)
}
outputModule <- function(input, output, session, ImProxy){
output$txt <- renderPrint({
paste(ImProxy$text1, "&", ImProxy$text2)
})
}
ui <- fluidPage(
outputModuleUI('OM')
)
server <- function(input, output, session){
#here is where I need to only pass vals to MyImProxy...
MyImProxy <- callModule(inputModule, 'IM')
callModule(outputModule, 'OM', MyImProxy)
}
shinyApp(ui, server) ```