Untitled
unknown
r
7 months ago
994 B
2
Indexable
Never
library(shiny) mUI <- function(id) { ns <- NS(id) tagList( textInput(ns("text"), "text", value = id), ) } mServer <- function(id) { moduleServer(id, function(input, output, session) { observe(updateTextInput(inputId = "text", value = kk())) |> bindEvent(kk(), ignoreInit = T) reactive(input$text) }) } ui <- fluidPage( mUI("m1"),mUI("m2"), textOutput("out"),textOutput("outB"), actionButton("p", "p") ) server <- function(input, output, session) { my_data <- list( a = list( b = mServer("m1"), c = mServer("m2") ) ) kk <<- reactiveVal("testík") observe(kk("ouye")) |> bindEvent(input$p, ignoreInit = T) output$out <- renderText(my_data$a$b()) output$outB <- renderText(my_data$a$c()) observe({ browser() a <- my_data$a$b() b <- my_data$a$c() print("-") }) |> bindEvent({ purrr::map(my_data$a, function(x) x()) }, ignoreInit = T) } shinyApp(ui, server, options = list(port = 1234, launch.browser = F))
Leave a Comment