-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stacks within modules #425
Comments
We have an example in the doc, where you can pass custom library(blockr)
library(shiny)
mod_ui <- function(id) {
uiOutput(shiny::NS(id)("stack"))
}
mod_server <- function(id) {
moduleServer(
id,
function(
input,
output,
session
) {
# "hello" or session$ns("hello") both fail
stack <- new_stack()
output$stack <- renderUI({
generate_ui(stack, id = session$ns("hello"))
})
generate_server(stack, id = "hello")
}
)
}
ui <- fluidPage(
theme = bslib::bs_theme(5L),
mod_ui("stack")
)
server <- function(input, output, session) {
mod_server("stack")
}
shinyApp(ui, server) If have to check why passing a name to stack fails in that case. |
When we call id <- coal(id, get_stack_name(x)) as What we need is something like this in id <- coal(id, tail(strsplit(get_stack_name(x), "-")[[1]], n = 1)) Example with one more level of parent module: library(blockr)
library(shiny)
mod_inner_ui <- function(id) {
uiOutput(shiny::NS(id)("stack"))
}
mod_inner_server <- function(id) {
moduleServer(
id,
function(
input,
output,
session
) {
stack <- new_stack(name = session$ns("pouet"))
output$stack <- renderUI({
generate_ui(stack)
})
generate_server(stack)
}
)
}
mod_outer_ui <- function(id) {
ns <- NS(id)
mod_inner_ui(ns("inner"))
}
mod_outer_server <- function(id) {
moduleServer(
id,
function(input, output, session) {
mod_inner_server("inner")
}
)
}
ui <- fluidPage(
theme = bslib::bs_theme(5L),
mod_outer_ui("ext")
)
server <- function(input, output, session) {
mod_outer_server("ext")
}
shinyApp(ui, server) |
We define stack names when creating the stack.
The hack is to manually change the
name
attributeEDIT: In the first example, the stack renders fine but underlying namespace is incorrect, none of the inputs of the stack work.
The text was updated successfully, but these errors were encountered: