shinymaterial (version 0.5.3)

material_spinner_show: Create a material preloader (spinner)

Description

Display a preloader (spinner) while server is busy.

Usage

material_spinner_show(session, output_id)

Arguments

session

The session object passed to function given to shinyServer.

output_id

The output id for which the spinner will be a placeholder for.

Examples

Run this code
# NOT RUN {
if(interactive()){
  library(shiny)
  library(shinymaterial)
  
  ui <- material_page(
    title = "Spinner Example",
    numericInput(inputId = "n", label = "", value = 10),
    plotOutput("n_plot")
 )
  
  server <- function(input, output, session) {
    
    output$n_plot <- renderPlot({
    
      #--- Show the spinner ---#
      material_spinner_show(session, "n_plot")
      
      #--- Simulate calculation step ---#
      Sys.sleep(time = 5)
      
      #--- Hide the spinner ---#
      material_spinner_hide(session, "n_plot")
      
      plot(1:input$n)
    })
    
  }
  shinyApp(ui = ui, server = server)
}
# }

Run the code above in your browser using DataCamp Workspace