snake_loader: Add the Snake Game to a Shiny App!

Description Usage Arguments Value Examples

View source: R/snake_loader_function.R

Description

Use the snake game to pass time during long running shiny operations.

Usage

1
2
snake_loader(outputId, header = "Play Snake while you wait!",
  controls = TRUE)

Arguments

outputId

The output id of the element that triggers the snake game loader; probably some output that takes a long time to load (or else there won't be time to play!)

header

The title to display over the game screen.

controls

Should text showing telling user to use the arrow keys appear below the game screen?

Value

A conditional panel that will load the snake game when the provided outputId is recalculating.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
library(shiny)
library(snakeLoadR)

shinyApp(
  shinyUI(
    fluidPage(
      fluidRow(
        column(width=10, offset=1, algin="left",
               actionButton("my_button", "Start Fake 30 Second Job"),
               uiOutput("my_output"),
        )
      ),
      snakeLoadR::snake_loader(outputId = "my_output",
                               header = "Play Snake while you wait!",
                               controls = TRUE)
    )
  ),
  shinyServer(function(input, output) {
    output$my_output <- renderUI({
      if(input$my_button != 0) Sys.sleep(30)
      HTML(paste0("<h3>Fake job completed <code>", input$my_button,"</code> times!</h3>"))
    })
  })
)

## End(Not run)

AdamSpannbauer/snakeLoadR documentation built on May 27, 2019, 12:16 p.m.