formattable icon indicating copy to clipboard operation
formattable copied to clipboard

Make formattable work with promises-package

Open simdadim opened this issue 4 years ago • 3 comments

Formattable-rendering is not working in shiny when using promises.

library(shiny)
library(formattable)
library(promises)
library(future)

ui <- fluidPage(
  formattableOutput("table")
)

server <- function(input, output, session) {
  output$table <- renderFormattable({
    future({mtcars}) %...>% formattable()
  })
}

shinyApp(ui, server)

This minimal example gives the error: no applicable method for 'as.htmlwidget' applied to an object of class "promise"

which seems to missing handling of how to convert a future-formattable into a html-widget in the renderFormattable-function.

https://rstudio.github.io/promises/

simdadim avatar Sep 17 '20 12:09 simdadim

Would you like to provide an example where other htmlwidget works with promises?

renkun-ken avatar Sep 17 '20 13:09 renkun-ken

I think this might be a place where its resolved in the DT-package: https://github.com/rstudio/DT/blob/c4cf873af528e5d28faa587246077f86709894a3/R/shiny.R#L81-L89

simdadim avatar Sep 17 '20 14:09 simdadim

I would be very interested in this too, any progress? I can't speak for the DT implementation, but hmtlWidget::shinyRenderWidget is supposed to support promises now, so I am not sure what the problem is and how to solve it.

ComeMaes avatar Jul 01 '21 07:07 ComeMaes