R Shiny: Updating an output before another (relatively long) computation is finished

不羁的心 提交于 2021-02-11 07:07:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!