Skip to content

How to combine 'foreach' with "shinybusy"? #40

@HuidongTian

Description

@HuidongTian

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)
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions