Skip to contents

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

Usage

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

Arguments

name

Name of the output to be rendered

rendering

Rendering expression to be sent.

session

Shiny session object.

Value

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

Examples

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)
}