Closed HugoGit39 closed 7 months ago
It looks to me like generate_data
runs instantaneously.
What are you trying to achieve?
Yeah correct, this is a simplified example.
My current app is huge where data is being loaded from Google Drive. This takes a couple of seconds where i would like to add a spinner over the whole app while its fetching the data via reactivePoll. Bascially like in the example, but the data isnt fetched what also happens here.
is waiter in general usable with a reactiveval?
It's because your function ends with waiter_hide
library(shiny)
library(ggplot2)
library(waiter)
# Function to generate random data
generate_data <- function() {
Sys.sleep(3)
data <- data.frame(
x = rnorm(50),
y = rnorm(50)
)
return(data)
}
# UI
ui <- fluidPage(
titlePanel("ReactivePoll Example"),
plotOutput("scatterplot")
)
# Server
server <- function(input, output, session) {
data <- reactivePoll(
intervalMillis = 10000,
session = session,
checkFunc = function() {
print(format(Sys.time(), "%M"))
},
valueFunc = function() {
waiter_show()
on.exit(waiter_hide())
generate_data()
}
)
# Scatterplot
output$scatterplot <- renderPlot({
ggplot(data(), aes(x = x, y = y)) +
geom_point() +
labs(title = "Random Scatterplot")
})
}
# Run the application
shinyApp(ui, server)
Thx! i thought I already tried on.exit(waiter_hide())
but somehow I didnt do it properly!
Hi
I dont know wether this is a real bug, however i would like to show a wating screen when data is generated and renewed using reactivePoll...but this doesnt work. Any idea why?