Shiny中的异步处理应该具有长时间运行的功能并将控制权交还给用户 . 但是,让用户知道计算在后台运行仍然是一件好事 . 我无法弄清楚如何构建异步进程以在后台运行并仍然显示进度指示器 . 下面是我一直在摆弄的示例代码 . 我认为进度指示器是一个问题,但表的创建似乎不适用于异步处理 .

library(shiny)
library(future)
library(promises)
plan(multiprocess)

shinyApp(
  ui = basicPage(
    tableOutput('table'),
    actionButton('goTable', 'Go table')
  ),

  server = function(input, output, session) {

    table_data <- reactive({

      # make reactive to button click
      input$goTable

      # Create a Progress object
      progress <- shiny::Progress$new()
      progress$set(message = "Building Table", value = 0)
      # Close the progress when this reactive exits (even if there's an error)
      on.exit(progress$close())

      # build up the table data
      future({
        this_dat <- NULL
        for(i in 1:5){
          Sys.sleep(1)
          this_dat <- rbind(this_dat, data.frame(i=i))
          # increment progress
          progress$inc(1/5)
        }
      })
      return(this_dat)
    })

    output$table <- renderTable({
       table_data()
    })    
  }
)