Learn R Programming

waiter (version 0.0.6)

waiter: Waiter

Description

Programatically show and hide loading screens.

Usage

use_waiter(include_js = TRUE)

show_waiter(html = "", color = "#333e48", logo = "")

show_waiter_on_load(html = "", color = "#333e48", logo = "")

hide_waiter_on_drawn(id)

hide_waiter()

update_waiter(html = "")

Arguments

include_js

Whether to include the Javascript dependencies, only set to FALSE if you use show_waiter_on_load.

html

HTML content of waiter, generally a spinner, see spinners.

color

Background color of loading screen.

logo

Logo to display.

id

Id of element to hide.

Functions

  • use_waiter: waiter dependencies to include anywhere in your UI but ideally at the top.

  • show_waiter_on_load: Show a waiter on page load, before the session is even loaded, include in UI after use_waiter.

  • show_waiter: Show waiting screen.

  • hide_waiter: Hide any waiting screen.

  • hide_waiter_on_drawn: Hide any waiting screen when the output is drawn, useful for outputs that take a long time to draw, use in ui.

Class

Arguments passed to show_waiter are passed to the initialisation method new.

  • Waiter: initiatlise a Waiter.

Methods

Public methods

Method new()

Usage

Waiter$new(html = "", color = "#333e48", logo = "")

Arguments

html

HTML content of waiter, generally a spinner, see spinners.

color

Background color of loading screen.

logo

Logo to display.

Details

Create a waiter.

Examples

\dontrun{Waiter$new()}

Method finalize()

Usage

Waiter$finalize()

Details

Hide the waiter.

Method show()

Usage

Waiter$show()

Details

Show the waiter.

Method hide()

Usage

Waiter$hide()

Details

Hide the waiter.

Method update_waiter()

Usage

Waiter$update_waiter(html = "")

Arguments

html

HTML content of waiter, generally a spinner, see spinners.

Details

Update the waiter's html content.

Method print()

Usage

Waiter$print()

Details

print the waiter

Examples

Run this code
# NOT RUN {
library(shiny)

ui <- fluidPage(
  use_waiter(), # dependencies
  show_waiter_on_load(spin_fading_circles()), #<U+00A0>shows before anything else 
  actionButton("show", "Show loading for 5 seconds")
)

server <- function(input, output, session){
  hide_waiter() #<U+00A0>will hide *on_load waiter
  
  observeEvent(input$show, {
    show_waiter(
      tagList(
        spin_fading_circles(),
        "Loading ..."
      )
    )
    Sys.sleep(3)
    hide_waiter()
  })
}

if(interactive()) shinyApp(ui, server)


## ------------------------------------------------
## Method `Waiter$new`
## ------------------------------------------------

# }
# NOT RUN {
Waiter$new()
# }

Run the code above in your browser using DataLab