foreach icon indicating copy to clipboard operation
foreach copied to clipboard

How to combine 'foreach' with "shinybusy"?

Open HuidongTian opened this issue 2 years ago • 0 comments

Hi, thanks for creating this excellent package!

I want to add a progress bar for "foreach" progress for my shiny-app. However, the progress bar stopped (at around 88%) before reaching to the end. I couldn't figure out why this issue happened, could you help? The following is a demo of the issue: ` library(shiny) library(shinybusy) library(doParallel); registerDoParallel(cores = 4)

n <- 100 f <- function(n){ m <- 0 function(...) { m <<- m + length(list(...)) - 1 Sys.sleep(0.1) update_modal_progress(value = m/n) } }

ui <- fluidPage( tags$h1("Modal with progress bar"), actionButton("sleep1", "Launch a long calculation") )

server <- function(input, output, session) { observeEvent(input$sleep1, { show_modal_progress_line() result <- foreach(i = 1:n, .combine = f(n)) %dopar% { rnorm(10) } remove_modal_progress() })

}

shinyApp(ui, server) `

HuidongTian avatar Mar 09 '23 11:03 HuidongTian