rstudio / promises

A promise library for R
https://rstudio.github.io/promises
Other
198 stars 19 forks source link

async with promises support for DT datatable #31

Open jacob7182 opened 6 years ago

jacob7182 commented 6 years ago

Hi, I had read in an earlier issue raised that Promises does not work with DT package, I tried the same and it gives the error " can only work with 2 dimensional data like data.frame or matrices" Is the issue still there with the latest version of shiny/promises on CRAN?

trafficonese commented 5 years ago

I think DT does work with promises. Consider the following example, where the iris is packed in a future and passed to renderDataTable:

So maybe the problem is with the data that you pass to DT. Could you include a small example where that error appears?

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

ui <- fluidPage(
  DT::dataTableOutput("table")  
)

server <- function(input, output, session) {
  dat <- reactive({
    future({ 
      Sys.sleep(2);
      iris
    })
  })

  output$table <- DT::renderDataTable({
    dat() %...>%
      head()
  })
}

shinyApp(ui, server)