I want to update the tabsetpanel immediately, and not wait untill finishing the download function. here you can find a simple code It has a button, and when it presed, it simulate a download, and update a tabsetpanel. I want to update the panel before finishing the download.
Thanks!
server <- function(input, output,session) {
observeEvent(input$goPlot,{
updateTabsetPanel(session, "inTabset",
selected = 'Summary'
)
output$plot <- renderPlot({
input$goPlot # Re-run when button is clicked
# Create 0-row data frame which will be used to store data
dat <- data.frame(x = numeric(0), y = numeric(0))
withProgress(message = 'Making plot', value = 0, {
# Number of times we'll go through the loop
n <- 10
for (i in 1:n) {
# Each time through the loop, add another row of data. This is
# a stand-in for a long-running computation.
dat <- rbind(dat, data.frame(x = rnorm(1), y = rnorm(1)))
# Increment the progress bar, and update the detail text.
incProgress(1/n, detail = paste("Doing part", i))
# Pause for 0.1 seconds to simulate a long computation.
Sys.sleep(1)
}
})
plot(dat$x, dat$y)
})
})
}
ui <- shinyUI(fluidPage(
actionButton('goPlot', 'Go plot'),
tabsetPanel(id = "inTabset",
tabPanel("Plot", plotOutput("plot")),
tabPanel("Summary")
)
)
)
shinyApp(ui = ui, server = server)