Learn R Programming

shinyCohortBuilder (version 0.4.0)

.sendOutput: Send output rendering

Description

Functional approach to rendering output. Equivalent of `output[[name]] <- rendering`.

Usage

.sendOutput(name, rendering, session = shiny::getDefaultReactiveDomain())

Value

No return value, used for side effect which is assigning rendering to the output object.

Arguments

name

Name of the output to be rendered

rendering

Rendering expression to be sent.

session

Shiny session object.

Examples

Run this code
if (interactive()) {
  library(shiny)
  library(shinyCohortBuilder)

  rendering <- function(x_max) {
    renderPlot({
      x <- seq(0, x_max, by = 0.01)
      plot(x, sin(x), type = "l")
    })
  }

  ui <- fluidPage(
    numericInput("xmax", "X Axis Limit", min = 0, max = 10, value = pi),
    plotOutput("out")
  )

  server <- function(input, output, session) {
    observeEvent(input$xmax, {
      .sendOutput("out", rendering(input$xmax))
    })
  }

  shinyApp(ui, server)
}

Run the code above in your browser using DataLab