JohnCoene / waiter

🕰️ Loading screens for Shiny
https://waiter.john-coene.com/
Other
495 stars 25 forks source link

Waitress for Shiny rmarkdown::render progress #104

Closed BerndMaier closed 2 years ago

BerndMaier commented 3 years ago

Hi, first thanks for this awesome package :+1:

This is more of a question than an issue with the package itself.

I wanted to ask if I can use waitress to replace the (not so nice looking) shiny withProgress for rendering markdown reports.

As waitress is much more beautiful.

Can waitress use the shiny::setProgress information from Markdown or sth like that to show the rendering progress?

Thank you very much and keep up the nice work, Bernd

JohnCoene commented 3 years ago

Good idea, let me think how this could work.

JohnCoene commented 3 years ago

I just pushed this feature. I cannot override the progress object that Shiny uses internally so I have to create separate functions.

library(shiny)
library(waiter)

ui <- fluidPage(
  useWaitress(),
  br(),
  actionButton(
    "load",
    "Load stuff"
  )
)

server <- function(input, output) {
  observeEvent(input$load, {
    withProgressWaitress({
      for (i in 1:15) {
        incProgressWaitress(1)
        Sys.sleep(0.25)
      }
    }, selector = "#load", max = 15, theme = "overlay-percent")
  })
}

shinyApp(ui, server)

Hope this helps.

BerndMaier commented 3 years ago

Thanks for the fast improvement - yeah, works fine, used the attendant as it looks really nice and allows extra messages :+1: