get_golem_options: Get all or one golem options

View source: R/with_opt.R

get_golem_optionsR Documentation

Get all or one golem options

Description

This function is to be used inside the server and UI from your app, in order to call the parameters passed to run_app().

Usage

get_golem_options(which = NULL)

Arguments

which

NULL (default), or the name of an option

Value

The value of the option.

Examples


# Define and use golem_options
if (interactive()) {
  # 1. Pass parameters to `run_app`

  # to set default value, edit run_app like this :

  run_app <- function(
  title = "this",
  content = "that"
  ) {
    with_golem_options(
      app = shinyApp(
        ui = app_ui,
        server = app_server
      ),
      golem_opts = list(
        p1 = p1,
        p3 = p3
      )
    )
  }

  # 2. Get the values from the UI side

  h1(get_golem_options("title"))

  # 3. Get the value from the server-side

  output$param <- renderPrint({
    paste("param p2 = ", get_golem_options("p2"))
  })
}


golem documentation built on Oct. 18, 2022, 5:09 p.m.