【发布时间】:2019-06-09 14:56:51
【问题描述】:
当我想渲染链接到单个观察者的多个输出时,它们会在计算两个输出之后渲染。如果输出之间的计算时间很长,则需要很长时间才能显示所有输出。
是否可以在 Shiny 应用程序中单独或并行渲染输出,链接到单个观察者?而不是等待渲染,直到计算出所有输出。
示例
library(shiny)
ui <- fluidPage(
actionButton('button', 'klik'),
textOutput('first'),
textOutput('second')
)
server <- function(input, output, session) {
observeEvent({input$button},{
output$first <- renderText({Sys.Date()})
Sys.sleep(10)
output$second <- renderText({Sys.Date()})
})
}
shinyApp(ui, server)
【问题讨论】:
-
我反对在
observeEvent中做任何繁重的事情,包括渲染 UI,看看模块 shiny.rstudio.com/articles/modules.html -
看这篇文章r-bloggers.com/…
标签: r parallel-processing shiny future shiny-reactivity