Skip to content

promises support for new shiny async #1209

Closed
@fabiangehring

Description

@fabiangehring

Shiny supports async evaluation in it's current dev (async branch merged a few days ago). Plotly does not seem to support this new functionaility yet.

The error of the following minimal app says: "no applicable method for 'ggplotly' applied to an object of class "promise""

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

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      sliderInput("n",
                  "Test:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),
    
    mainPanel(
      plotlyOutput("plot")
    )
  )
)

server <- function(input, output) {
  getData <- function(n) {
    data.frame(x = sample(n), y = sample(n))
  }
  
  data <- reactive({
    n <- input$n
    future(getData(n))
  })
 
  output$plot <- renderPlotly({
    data() %...>%
      plot_ly(x = ~x, y = ~y)
  })
}

shinyApp(ui = ui, server = server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions