Giter Site home page Giter Site logo

waiter's Introduction

Loading screens for Shiny

Travis build status R-CMD-check CircleCI build status CRAN status

Website | Demo | Get Started | Cheat Sheet

The waiter lets you programmatically show and hide partial or full page loading screens with spinners or loading bars to keep your users patiently waiting as you load or compute fancy things.

Feature Waiter Waitress Hostess
Progress Bar ✔️ ✔️ ✔️
Full Screen ✔️ ✔️ ✖️
Works with waiter ✔️ ✖️ ✔️
Spinner ✔️ ✖️ ✖️
Updatable ✔️ ✖️ ✖️
Notifications ✖️ ✔️ ✖️

Examples

Below are simple examples of applications that use the package, consult the website for more.

Waiter

To use the waiter:

  1. Include use_waiter in your UI.
  2. Trigger show_waiter to show the waiting screen.
  3. Eventually trigger hide_waiter to hide the loading screen.
library(shiny)
library(waiter)

ui <- fluidPage(
  use_waiter(), # include dependencies
  waiter_show_on_load(),
  actionButton("show", "Show loading for 3 seconds")
)

server <- function(input, output, session){

  observeEvent(input$show, {

    waiter_show( # show the waiter
      spin_fading_circles() # use a spinner
    )

    Sys.sleep(3) # do something that takes time
    
    waiter_hide() # hide the waiter
  })
  
}

shinyApp(ui, server)

The waiter includes more options to customise the spinner, the background, show the waiter on load, etc.

Waitress

To use the waitress:

  1. Include use_waitress in your UI.
  2. Initialise a waitress from the Waitress object with the new method.
  3. You must then call the start.
  4. On the waitress object use the increase method to increase the progress bar.
  5. Use the hide method when done.
library(shiny)
library(waiter)

ui <- fluidPage(
  use_waitress(),
  p("App content")
)

server <- function(input, output){

  # call the waitress
  waitress <- Waitress$
    new(theme = "overlay-percent")$
    start() # start

  for(i in 1:10){
    waitress$inc(10) # increase by 10%
    Sys.sleep(.3)
  }

  # hide when it's done
  waitress$close() 

}

shinyApp(ui, server)

There are more options to the waitress, you can have it overlay any element (such as the navbar), automagically increment it, etc.

Get it

You can install waiter from CRAN.

install.packages("waiter")

Or the development version from Github with:

install.packages("remotes")
remotes::install_github("JohnCoene/waiter")

Please note that the ‘waiter’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

waiter's People

Contributors

johncoene avatar jhk0530 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.