Async Programming in Shiny

dt
async

#1

I am working on a Shiny application which will be used by multiple users and involves expensive operations (pulling data from APIs). Since I am currently testing the application, I use the following function to toggle between whether async programming is to be used or not:

MDIS_ASYNC <- TRUE

if (MDIS_ASYNC) {
  library(promises)
  library(future)
  plan(multiprocess)
  future <- future::future
  then <- promises::then
} else {
  future <- base::identity
  then <- function(promise, onFulfilled) { onFulfilled(promise) }
}

I am then trying to render a data table using the following code:

fetch_data_from_stratum <- reactive({
  req(ShipId())
  req(startperiod())
  req(stopperiod())
  id <- ShipId()$VesselID[1]
  strtp <- as.character(startperiod())
  stpp <- as.character(stopperiod())
  shinyjs::show("page_shield")
  future({
    list(
      data=fetch_voyage_data(id,strtp,stpp)
    )
  })
})
#
voyData <- reactive({
  then(
    fetch_data_from_stratum(),
    onFulfilled = function(value){
      shinyjs::hide("page_shield")
      value$data
    }
  )
})
output$voyageData <- renderDT({
  req(voyData())
  then(
    voyData(),
    onFulfilled = function(value){
      datatable(value)
    }
  )
})

am able to render voyageData DT when I am not using async programming ( MDIS_ASYNC <- FALSE ). But when it is true, I get the following error:

Warning: Error in datatable: 'data' must be 2-dimensional (e.g. data frame or matrix)

I have just installed the latest Github version of DT.
Can someone help here please?