shinyhttr (version 1.0.0)

progress: Add a progress bar compatible with `shinyWidgets::updateProgressBar()`.

Description

Add a progress bar to request just like the vanilla `httr::progress()` but with capability to talk to `shinyWidgets::updateProgressBar()` by giving the session and id arguments to it.

Usage

progress(session, id, type = c("down", "up"), con = stdout(),
  title = NULL, status = NULL, range_value = NULL,
  unit_mark = "%")

Arguments

session

(from `shinyWidgets::updateProgressBar()`` doc) The 'session' object passed to function given to shinyServer.

id

(from `shinyWidgets::updateProgressBar()` doc) An id used to update the progress bar.

type

(from `httr::progress()`` doc) Type of progress to display: either number of bytes uploaded or downloaded.

con

(from `httr::progress()` doc) Connection to send output too. Usually stdout() or stderr.

title

(from `shinyWidgets::updateProgressBar()` doc) character, optional title.

status

(from `shinyWidgets::updateProgressBar()` doc) Color, must be a valid Bootstrap status : primary, info, success, warning, danger.

range_value

(from `shinyWidgets::updateProgressBar()` doc) Default is to display percentage ([0, 100]), but you can specify a custom range, e.g. -50, 50.

unit_mark

(from `shinyWidgets::updateProgressBar()` doc) Unit for value displayed on the progress bar, default to "%".

See Also

progress, progressBar, updateProgressBar

Examples

Run this code
# NOT RUN {
if (interactive()) {
  
  library(shiny)
  library(shinyWidgets)
  library(shinyhttr)
  
  ui <- fluidPage(
    
    sidebarLayout(
      
      NULL,
      
      mainPanel(
        actionButton('download', 'Download 100MB file...'),
        tags$p("see R console to compare both progress bars."),
        progressBar(
          id = "pb",
          value = 0,
          title = "",
          display_pct = TRUE
        )
      )
    )
  )
  
  server <- function(input, output, session) {
    observeEvent(input$download, {
      httr::GET(
        url = "https://speed.hetzner.de/100MB.bin",
        progress(session, id = "pb")
      )
    })
  }
  
  shinyApp(ui, server)
}
# }

Run the code above in your browser using DataCamp Workspace