Debian Codegraph @

inst/app_template/R/example-module.R

raw
1 exampleModuleUI <- function(id, label = "Counter") {
2 # All uses of Shiny input/output IDs in the UI must be namespaced,
3 # as in ns("x").
4 ns <- NS(id)
5 tagList(
6 actionButton(ns("button"), label = label),
7 verbatimTextOutput(ns("out"))
8 )
9 }
10
11 exampleModuleServer <- function(id) {
12 # moduleServer() wraps a function to create the server component of a
13 # module.
14 moduleServer(
15 id,
16 function(input, output, session) {
17 count <- reactiveVal(0)
18 observeEvent(input$button, {
19 count(count() + 1)
20 })
21 output$out <- renderText({
22 count()
23 })
24 count
25 }
26 )
27 }