Skip to content

Commit 3b87f64

Browse files
Add source-code comments to clarify with_progress() + add one invisible() for consistency [#178]
1 parent bebf17c commit 3b87f64

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: progressr
2-
Version: 0.16.0-9003
2+
Version: 0.16.0-9005
33
Title: An Inclusive, Unifying API for Progress Updates
44
Description: A minimal, unifying API for scripts and packages to report progress updates from anywhere including when using parallel processing. The package is designed such that the developer can to focus on what progress should be reported on without having to worry about how to present it. The end user has full control of how, where, and when to render these progress updates, e.g. in the terminal using utils::txtProgressBar(), cli::cli_progress_bar(), in a graphical user interface using utils::winProgressBar(), tcltk::tkProgressBar() or shiny::withProgress(), via the speakers using beepr::beep(), or on a file system via the size of a file. Anyone can add additional, customized, progression handlers. The 'progressr' package uses R's condition framework for signaling progress updated. Because of this, progress can be reported from almost anywhere in R, e.g. from classical for and while loops, from map-reduce API:s like the lapply() family of functions, 'purrr', 'plyr', and 'foreach'. It will also work with parallel processing via the 'future' framework, e.g. future.apply::future_lapply(), furrr::future_map(), and 'foreach' with 'doFuture'. The package is compatible with Shiny applications.
55
Authors@R: c(person("Henrik", "Bengtsson",

R/make_calling_handler.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ make_calling_handler <- function(handlers) {
66
handler <- handlers[[kk]]
77
if (handler(p)) finished <- TRUE
88
}
9-
finished
9+
invisible(finished)
1010
}
1111
} else {
1212
calling_handler <- handlers[[1]]

R/with_progress.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ with_progress <- function(expr, handlers = progressr::handlers(), cleanup = TRUE
157157
## Flag indicating whether nor not with_progress() exited due to an error
158158
status <- "incomplete"
159159

160-
## Tell all progression handlers to shutdown at the end and
160+
## Tell all progression handlers to shut down at the end and
161161
## the status of the evaluation.
162162
if (cleanup) {
163163
on.exit({
@@ -238,8 +238,11 @@ with_progress <- function(expr, handlers = progressr::handlers(), cleanup = TRUE
238238
calling_handler(control_progression("unhide"))
239239
}
240240
}
241-
242-
calling_handler(p)
241+
242+
## Let the registered 'progressr' calling handlers process
243+
## the 'progression' condition. If the progressor completed,
244+
## then 'finished' is TRUE (which we currently don't use)
245+
finished <- calling_handler(p)
243246
},
244247

245248
interrupt = handle_interrupt_or_error,

0 commit comments

Comments
 (0)