问题
I have the following problem. My shiny app is basically doing the following on the server side after a button is clicked:
observe({
isolate({
## Here are a lots of computations with the results shown iteratively using invalidateLater():
})
if( computations not done ){
invalidateLater(500)
} else {
#Once the computations are done, I create a final output table and also a image.
output$example <- renderTable( something based on the computations )
output$example2 <- renderPlot( something based on the computations )
#Here comes code to save the results of the computation in a database
})
Here is my problem: Saving to the database takes like 3 seconds. This isn't the end of the world, but my problem is that the final output is only rendered after the saving is finished.
I'd like to change this, that is I'd like to first render the output (which really doesn't take long, maybe half a second). I tried different things like putting saving code into another observe and/or isolate block, but I couldn't get it done. Is there a way to do it?
来源:https://stackoverflow.com/questions/61290448/r-shiny-updating-an-output-before-another-relatively-long-computation-is-fini