JohnCoene / waiter

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

waiter functionality similar to withSpinner #105

Closed giadasp closed 2 years ago

giadasp commented 3 years ago

Dear waiter developers, I find your package really awesome but I cannot figure out how I can reproduce the withSpinner function of the shinycssloader package. I display output elements dinamically so I cannot use their ids to assign a waiter to them. I tried to use autoWaiter() but it works only for output elements for which I call a renderPlot function. It seems it does not work for generic output elements like outputUI. I make an example: Before, I created a div in this way:

tags$div(withSpinner(uiOutput("output_name")))

and when I call output$output_name <- renderUI(tags$div("hello"))

the spinner appears and it hides when the UI is rendered.

Since I want to use only your package for this kind of tasks, I'm asking you if there is a way to reproduce this behaviour. Thanks.

Giada

JohnCoene commented 3 years ago

Let me explore how this functionality could be integrated with waiter. (sorry for the late response)

JohnCoene commented 2 years ago

I just added this to the dev version from Github: withWaiter

Reinstall the latest version

# install.packages("remotes")
remotes::install_github("JohnCoene/waiter")

Try

library(shiny)
library(waiter)

ui <- fluidPage(
  useWaiter(),
  actionButton("draw", "plot"),
  withWaiter(
    plotOutput("plot")
  )
)

server <- function(input, output, session){
  output$plot <- renderPlot({
    input$draw
    Sys.sleep(5)
    plot(cars)
  })
}

shinyApp(ui, server)
JohnCoene commented 2 years ago

I'm assuming this is sorted and closing, feel free to reopen if it is not

giadasp commented 2 years ago

When are you going to update the package on CRAN?

JohnCoene commented 2 years ago

The latest version 0.2.4 includes withWaiter. What are you after?

apalacio9502 commented 2 years ago

Hi Jhon, the new functionality is very good. However it doesn't work for me for plotly or DT.

Here is an example with plotly.

`library(shiny) library(waiter)

ui <- fluidPage( useWaiter(), actionButton("draw", "plot"), withWaiter( plotlyOutput("plot")) )

server <- function(input, output, session){ output$plot <- renderPlotly({ input$draw Sys.sleep(5) x <- c(1:100) random_y <- rnorm(100, mean = 0) data <- data.frame(x, random_y) plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines') }) }

shinyApp(ui, server)`

HugoGit39 commented 1 year ago

Does it already works with plotly? Cause I also can not get it to work