High-Performance Open-Source Archive
The waiter package comes with a few members of staff but the core one is the waiter which will let you show full page or partial loading screens in your shiny application.
It’s fairly straightforward:
useWaiter anywhere in your UI.Waiter$new()Waiter$show()Waiter$hide()A basic example could be like this, upon clicking a button we display a full page loading screen.
library(shiny)
library(waiter)
ui <- fluidPage(
useWaiter(), # include dependencies
actionButton("show", "Show loading for 3 seconds")
)
server <- function(input, output, session){
# create a waiter
w <- Waiter$new()
# on button click
observeEvent(input$show, {
w$show()
Sys.sleep(3)
w$hide()
})
}
shinyApp(ui, server)Make sure you include the dependencies with
useWaiteror nothing will work.
By default the waiter will show a spinner, 1) you can choose from
more than 100
spinners 2) you are by no means limited to a spinner since the
html argument takes any htmltools or shiny tag. Below we
change the spinner, add some text and change the background color.
library(shiny)
library(waiter)
waiting_screen <- tagList(
spin_flower(),
h4("Cool stuff loading...")
)
ui <- fluidPage(
useWaiter(), # include dependencies
actionButton("show", "Show loading for 3 seconds")
)
server <- function(input, output, session){
observeEvent(input$show, {
waiter_show(html = waiting_screen, color = "black")
Sys.sleep(3) # do something that takes time
waiter_hide()
})
}
shinyApp(ui, server)Visit the full waiter documentation to learn how to further customise your waiting screen, have it appear on parts of the application, show loading bars, and more.
Need mirroring services?
Contact our team at info@vpspulse.com.
Mirror powered by VPSpulse
Infrastructure sponsored by VPSPulse & Secure Payments by ArionPay.