futureverse / futureverse/progressr
IDEA: Signal amount=0 when receiving updates from nested progressors
- Dominant language
- R
- Stars
- 299
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
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:
```r
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
```r
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
Contributor guide
Assessment
This issue has not been assessed yet.