我試圖構建一個閃亮的應用程序,通過不同的渲染*函數輸出幾個結果。強制渲染已計算的無功元素
問題是,其中一個結果需要一些時間來計算。所以我想閃亮的儘快呈現快速結果。
下面是一些代碼來說明
# ui.R
library(shiny)
shinyUI(fluidPage(
textOutput("res1"),
textOutput('res2')
))
# server.R
library(shiny)
shinyServer(function(input, output) {
output$res1 = renderText({
"shows up instantly"
})
output$res2 = renderText({
Sys.sleep(3)
"shows up after 3 sec"
})
})
現在,網頁保持爲空3秒,這兩個元件被同時呈現。
我的問題如下:是否有可能強制output$res1
在output$res2
之前執行,並且在長計算開始之前將其結果發送到瀏覽器?
謝謝!然而,它不能解決我的問題,因爲更復雜的輸出。 – jey1401