I refer to the above link, which I think is what I need to solve the issue...
My original code is below:
output$RowsRuns <- renderUI({
section <- as.integer(input$section)
date_start <- as.character(input$FromDate)
date_end <- as.character(input$ToDate)
RawDataSetOutputs <- get_raw_dataset(section,date_start,date_end))
RowsRuns <- paste0('Rows of Run: ',RawDataSetOutputs[[1]])
HTML(RowsRuns)
})
which the long-running computation intensive calculations is from the function 'get_raw_dataset' which took about more than 2 minutes to execute. It is able to display its output 'RowsRuns' after more than 2 minutes, and will affect other part of the Shiny application afterwards.
Hence, I start to look into ' Scaling Shiny with async' and my new code is now:
library(promises)
library(future)
plan(multisession)
r <- reactive({
section <- as.integer(input$section)
date_start <- as.character(input$FromDate)
date_end <- as.character(input$ToDate)
future(get_raw_dataset(section,date_start,date_end)) %...>% RawDataSetOutputs
})
output$RowsRuns <- renderUI({
r() %...>% {
RowsRuns <- paste0('Rows of Run: ',RawDataSetOutputs[[1]])
HTML(RowsRuns)
}
})
However, with the above new code, now the application is smooth and does not 'hang', but its output does not display. Did I do my code correctly when using 'future'?
Thanks.