Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDEA: Signal amount=0 when receiving updates from nested progressors #107

Open
HenrikBengtsson opened this issue Mar 23, 2021 · 0 comments

Comments

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Mar 23, 2021

When there are nested progressors, only the first one is listened to. Any progress conditions signaled by nested progressors are ignored. Here's an example of nested progressors:

library(progressr)
handlers(handler_progress(format=":spin :message [:bar] :percent"))

foo <- function(n) {
  p <- progressor(n)
  lapply(seq_len(n), FUN = function(ii) {
    p(sprintf("foo(%d)", ii))
    Sys.sleep(0.5)
  })
}

bar <- function(n) {
  p <- progressor(n)
  lapply(seq_len(n), FUN = function(ii) {
    foo(n = 5)
    p(sprintf("bar(%d)", ii))
  })
}

Calling

y <- bar(10)

will only report on bar() updates.

However, we could make use of those conditions by doing an amount=0 update, i.e. to communicate "still alive", which may for instance update a "spinner".

The code that drops/ignore nested progressors is in:

https://github.com/HenrikBengtsson/progressr/blob/a2cb9af430784fd46f89022d467755fff2b73d76/R/make_progression_handler.R#L318-L323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant