JohnCoene / waiter

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

Waitress notification with infinite = TRUE does not close #109

Open vituri opened 3 years ago

vituri commented 3 years ago

Hi, John!

I use your package in a lot of shinyapps, and up until version 2.2 the below code worked as expected:

library(shiny)
library(waiter)
library(magrittr)

ui <- fluidPage(
  useWaitress(),
  actionButton("btn", "render"),
  plotOutput("plot", height = "90vh")
)

server <- function(input, output){
  some_data = reactive({
    waitress <- Waitress$new(theme = "overlay-opacity", infinite = TRUE)
    waitress$notify('Downloading data...')

    Sys.sleep(2)

    waitress$close()
  }) %>% 
    bindEvent(input$btn)

  output$plot <- renderPlot({
    some_data()

    hist(runif(100))
  })
}
shinyApp(ui, server)

I have some slow download operations running on reactives and I like to show an infinite notification, and close it when the slow part is done (usually I close one waitress and exhibit another). But in version 2.3 and 2.4 the w$close() doesn't work anymore.

image

Do you know any fix for that?

vituri commented 2 years ago

Update: the problem is more general. The whole Waitress does not disappear when it should. I am using waiter 0.2.5.

Here is an example:

library(shiny)
library(waiter)

ui <- fluidPage(
  useWaitress(),
  actionButton("btn", "render"),
  plotOutput("plot", height = "90vh")
)

server <- function(input, output){

  waitress <- Waitress$new(theme = "overlay-percent", min = 0, max = 10)

  output$plot <- renderPlot({
    input$btn

    # use notification
    waitress$notify('This text should disappear')

    for(i in 1:5){
      waitress$inc(1) # increase by 10%
      Sys.sleep(.1)
    }

    hist(runif(100))
    waitress$close() # hide when done
  })

}

shinyApp(ui, server)

and the notification:

Captura de tela de 2022-03-02 12-29-46