progress: Add a progress bar compatible with...

Description Usage Arguments See Also Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)
}

shinyhttr documentation built on July 16, 2020, 5:07 p.m.