Skip to contents

Specify a function that uses actions and the request object to choose which Shiny UI to serve.

Usage

change_scene(..., fall_through = default_ui)

Arguments

...

One or more shiny_scenes.

fall_through

A ui to display if no scenes are valid. The default value, default_ui(), returns an HTTP 422 status code indicating that the request cannot be processed.

Value

A function that processes the request object to deliver a Shiny ui.

Examples

scene1 <- set_scene(
  "A shiny ui",
  req_has_query("scene", 1)
)
scene2 <- set_scene(
  "Another shiny ui",
  req_has_query("scene", 2)
)

ui <- change_scene(
  scene1,
  scene2
)
ui
#> function (request) 
#> {
#>     for (scene in scenes) {
#>         if (!length(scene$actions) || purrr::every(scene$actions, 
#>             ~.x$check_fn(request))) {
#>             return(.parse_ui(scene$ui, request))
#>         }
#>     }
#>     return(.parse_ui(fall_through, request))
#> }
#> <bytecode: 0x55fc8b7bd9a8>
#> <environment: 0x55fc8b7c3eb0>
#> attr(,"http_methods_supported")
#> [1] "GET"