VincentGuyader / asap

Other
1 stars 1 forks source link

asap

The goal of asap is to help you render async

Installation

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("VincentGuyader/asap")

Example

library(shiny)
library(promises)
library(future)
library(asap)
plan(multisession)

ui <- fluidPage(
  column(6, plotOutput("one")),
  column(6, plotOutput("two")),
  column(6, plotOutput("three")),
  column(6, plotOutput("four"))
)

server <- function(input, output, session) {

  plotiris <- reactiveVal()
  plotiris(NULL)

  update_asap(what = ~{
    Sys.sleep(8);
    iris},to = plotiris)

  output$one <- renderPlot({
    req(plotiris())
    plot(plotiris())
  })

  output$two <- renderPlot({
    plot(airquality)
  })
  output$three <- renderPlot({
    plot(mtcars)
  })
  output$four <- renderPlot({
    plot(cars)
  })
}

shinyApp(ui, server)