R/mod_test.R

Defines functions mod_test_server mod_test_ui

#' test UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd 
#'
#' @importFrom shiny NS tagList 
mod_test_ui <- function(id, label = "Counter") {
  ns <- NS(id)
  tagList(
    actionButton(ns("button"), label = label),
    verbatimTextOutput(ns("out"))
  )
}
    
#' test Server Function
#'
#' @noRd 
mod_test_server <- function(id) {
  moduleServer(
    id,
    function(input, output, session) {
      count <- reactiveVal(0)
      observeEvent(input$button, {
        count(count() + 1)
      })
      output$out <- renderText({
        count()
      })
      count
    }
  )
}
    
## To be copied in the UI
# mod_test_ui("counter1", "Counter #1")
    
## To be copied in the server
# mod_test_server("counter1")


 
zac-garland/shiny.proxy.golem documentation built on Sept. 1, 2020, 12:11 a.m.