File: without_progress.R

package info (click to toggle)
r-cran-progressr 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,132 kB
  • sloc: sh: 13; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#' @details
#' `without_progress()` evaluates an expression while ignoring all
#' progress updates.
#'
#' @rdname with_progress
#' @export
without_progress <- function(expr) {
  progressr_in_globalenv("allow")
  on.exit(progressr_in_globalenv("disallow"))

  ## Deactive global progression handler while using without_progress()
  global_progression_handler(FALSE)
  on.exit(global_progression_handler(TRUE), add = TRUE)

  withCallingHandlers({
    res <- withVisible(expr)
  }, progression = function(p) {
    invokeRestart("muffleProgression")
  })
  
  if (isTRUE(res$visible)) {
    res$value
  } else {
    invisible(res$value)
  }
}