Creates a teal_modules
object.
modules.Rd
This function collects a list of teal_modules
and teal_module
objects and returns a teal_modules
object
containing the passed objects.
This function dictates what modules are included in a teal
application. The internal structure of teal_modules
shapes the navigation panel of a teal
application.
Arguments
- ...
parameters passed to
toString
- label
(
character(1)
) label of modules collection (default"root"
). If using thelabel
argument then it must be explicitly named. For examplemodules("lab", ...)
should be converted tomodules(label = "lab", ...)
- x
teal_modules
- indent
(
integer
) indent level; eachsubmodule
is indented one level more
Value
object of class teal_modules
. Object contains following fields
label
: taken from thelabel
argumentchildren
: a list containing objects passed in...
. List elements are named after theirlabel
attribute converted to a validshiny
id.
(character
)
Examples
library(shiny)
app <- init(
data = teal_data(dataset("iris", iris)),
modules = modules(
label = "Modules",
modules(
label = "Module",
module(
label = "Inner module",
server = function(id, data) {
moduleServer(
id,
module = function(input, output, session) {
output$data <- renderDataTable(data[["iris"]]())
}
)
},
ui = function(id) {
ns <- NS(id)
tagList(dataTableOutput(ns("data")))
},
datanames = "all"
)
),
module(
label = "Another module",
server = function(id) {
moduleServer(
id,
module = function(input, output, session) {
output$text <- renderText("Another module")
}
)
},
ui = function(id) {
ns <- NS(id)
tagList(textOutput(ns("text")))
},
datanames = NULL
)
)
)
#> module "Another module" server function takes no data so "datanames" will be ignored
if (interactive()) {
runApp(app)
}