【发布时间】:2019-09-12 15:20:12
【问题描述】:
我需要定期刷新信息框中显示的数据,但每次更新时都会呈现一个新的信息框,从而导致用户体验不佳。
我尝试过使用 futures/promises 进行异步处理,但 renderinfobox 仍然会在数据更新时呈现一个新框。这是我的代码:
invalidateLater(30000)
results <-future({testFuture()})
return(value(results))
我希望能够在整个查询期间更新信息框的基础数据,而不会使 ui 元素变暗。
【问题讨论】:
-
如果您包含一个简单的reproducible example,其中包含可用于测试和验证可能解决方案的示例输入和所需输出,则更容易为您提供帮助。
-
我没有可以分享的可重现示例。就像我连接到数据库以运行查询以更新信息框一样。我遇到的问题是,当我运行 aync 查询时,信息框会在整个查询期间呈现,从而导致用户体验不太理想。有 renderinfobox 经验的人会确切地知道我在说什么。
-
output$example <- renderInfoBox({values <- future({exampleFunction})infoBox("example box", value = prettyNum(as.numeric(values[1]),big.mark = ","), subtitle = HTML(paste(values[-1], collapse = ' <br>')), icon = icon("server"), color = 'blue')})<code>