Hi
I extend the example of https://shiny.rstudio.com/articles/modules.html with a tabset. First tab is handled in the 'top-app', the second tab is handle by the module. My question is, how i can access values from the 'top-app' in the module and vice versa from the module in the 'top-app'. For clarification, I added my two questions directly in the code.
counterButton <- function(id, label = "Counter") {
ns <- NS(id)
tagList(
actionButton(ns("button"), label = label),
verbatimTextOutput(ns("out"))
)
}
counterServer <- function(id) {
moduleServer(
id,
function(input, output, session) {
### Question 1: Can I get here the value of 'nInput'
count <- reactiveVal(0)
observeEvent(input$button, {
count(count() + 1)
})
output$out <- renderText({
count()
})
count
}
)
}
ui <- fluidPage(
tabsetPanel(
tabPanel("tab1",numericInput("nInput","Numeric Input",value=10)),
tabPanel("tab2",counterButton("counter1", "Counter #1"))
)
)
server <- function(input, output, session) {
counterServer("counter1")
### Question 2: Can I get here the value of 'out'?
}
shinyApp(ui, server)