Hi,
I found the session$sendCustomMessage will also block the main thread when transferring some "large data" from R to javascript. I would like to ask if we could make it asynchronously? I found that shiny for python supports "async" method, but have not find a way in shiny for R. Any suggestion would be great appreciated!
Thanks.
blocked_app.R modified from ExtendedTask example:
library(shiny)
library(bslib)
ui <- page_fluid(
p("The time is ", textOutput("current_time", inline=TRUE)),
hr(),
numericInput("x", "x", value = 1),
numericInput("y", "y", value = 2),
input_task_button("btn", "Add numbers"),
textOutput("sum")
)
server <- function(input, output, session) {
large_df <- data.frame(
id = 1:10000000,
value1 = rnorm(10000000),
value2 = runif(10000000),
category = sample(LETTERS, 10000000, replace = TRUE)
)
output$current_time <- renderText({
invalidateLater(1000)
format(Sys.time(), "%H:%M:%S %p")
})
sum_values <- eventReactive(input$btn, {
##Sys.sleep(5)
##input$x + input$y
session$sendCustomMessage(type = "custom", large_df)
})
output$sum <- renderText({
sum_values()
})
}
shinyApp(ui, server)