I have a Shiny Dashboard with many graphs, all of which take a few seconds to build. As soon as the latter builds, they are all displayed. I would like each chart to be displayed as soon as it ends. I understand that R is single-threaded, but it seems that there should be a way to “return execution to display code” or something like that.
This code demonstrates the problem:
library(shiny)
ui <- fluidPage(
title = "Page loading test"
, h1("Page loading test")
, plotOutput("plot1")
, plotOutput("plot2")
, plotOutput("plot3")
, plotOutput("plot4")
)
server <- function(input, output) {
output$plot1 <- renderPlot({
Sys.sleep(10)
plot(rnorm(50))
})
output$plot2 <- renderPlot({
Sys.sleep(10)
plot(rnorm(50))
})
output$plot3 <- renderPlot({
Sys.sleep(10)
plot(rnorm(50))
})
output$plot4 <- renderPlot({
Sys.sleep(10)
plot(rnorm(50))
})
}
shinyApp(ui = ui, server = server)
Dreams are simply emulating slow execution.
40 . , 10 , 1, 10 plot2 .. , UpdatePage(), ?
, , , .
, , , .:)