Skip to contents

Launches one of the example apps shipped with the package, mirroring shiny::runExample(). The examples are the same apps published as editable editors on the package website.

Usage

iridExample(
  example = NA,
  port = getOption("shiny.port"),
  launch.browser = getOption("shiny.launch.browser", interactive()),
  host = getOption("shiny.host", "127.0.0.1"),
  display.mode = c("showcase", "normal", "auto")
)

Arguments

example

Name of the example to run (e.g. "todo", "old-faithful") — the same name used in its website URL. If omitted, the available examples are listed.

port

The TCP port the application should listen on. Defaults to getOption("shiny.port"), or a random port if unset.

launch.browser

If TRUE, the system's default web browser is launched automatically. Defaults to TRUE in interactive sessions.

host

The IPv4 address the application should listen on. Defaults to getOption("shiny.host", "127.0.0.1").

display.mode

The display mode. Defaults to "showcase" — the annotated source shown alongside the running app; use "normal" to run the app by itself, or "auto" to defer to the app's own setting.

Value

If example is supplied, launches the app and blocks until it is stopped. Otherwise returns the available example names invisibly as a character vector (after listing them).

Details

Called with no argument (or an unrecognised name), it lists the available examples instead of launching one.

Some examples depend on packages beyond irid's hard dependencies (e.g. bslib, plotly). The runner checks for these up front and, if any are missing, stops with a message naming what to install. A couple of examples (codemirror, plotly) also load JavaScript from a CDN at runtime, so they need an internet connection even when run locally.

By default the app runs in Shiny's showcase display mode, so the annotated source appears beside the running app (as with shiny::runExample()). Pass display.mode = "normal" to run the app on its own.

The remaining arguments mirror shiny::runExample().

Examples

# List the available examples
iridExample()
#> Available irid examples:
#>  cards
#>  codemirror
#>  composing
#>  counter
#>  each-heterogeneous
#>  each-nested
#>  old-faithful
#>  optimistic-updates
#>  plotly
#>  shiny-interop
#>  temperature
#>  todo
#>  Run one with e.g. `iridExample("cards")`.

if (interactive()) {
  iridExample("todo")
}