shiny_progress: Wrapper of shiny progress that can run without shiny

shiny_progressR Documentation

Wrapper of shiny progress that can run without shiny

Description

Wrapper of shiny progress that can run without shiny

Usage

shiny_progress(
  title,
  max = 1,
  ...,
  quiet = FALSE,
  session = shiny::getDefaultReactiveDomain(),
  shiny_auto_close = FALSE,
  log = NULL,
  outputId = NULL
)

Arguments

title

the title of the progress

max

max steps of the procedure

...

passed to initialization method of Progress

quiet

whether the progress needs to be quiet

session

shiny session domain

shiny_auto_close

whether to close the progress once function exits

log

alternative log function

outputId

the element id of progressOutput, or NULL to use the default shiny progress

Value

a list of functions that controls the progress

Examples


{
  progress <- shiny_progress("Procedure A", max = 10)
  for(i in 1:10){
    progress$inc(sprintf("Step %s", i))
    Sys.sleep(0.1)
  }
  progress$close()

}

if(interactive()){
  library(shiny)

  ui <- fluidPage(
    fluidRow(
      column(12, actionButton("click", "Click me"))
    )
  )

  server <- function(input, output, session) {
    observeEvent(input$click, {
      progress <- shiny_progress("Procedure B", max = 10,
                                 shiny_auto_close = TRUE)
      for(i in 1:10){
        progress$inc(sprintf("Step %s", i))
        Sys.sleep(0.1)
      }
    })
  }

  shinyApp(ui, server)
}


shidashi documentation built on June 21, 2022, 5:05 p.m.