首页 > 解决方案 > R Shiny:在另一个(相对较长的)计算完成之前更新输出

问题描述

我有以下问题。单击按钮后,我闪亮的应用程序基本上在服务器端执行以下操作:

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

})

这是我的问题:保存到数据库大约需要 3 秒。这不是世界末日,但我的问题是最终输出仅在保存完成后才呈现。

我想改变这一点,那就是我想先渲染输出(这真的不需要很长时间,也许半秒)。我尝试了不同的方法,例如将代码保存到另一个观察和/或隔离块中,但我无法完成。有没有办法做到这一点?

标签: rshiny

解决方案


推荐阅读