Skip to contents

Wrapper function that executes an expression with optional progress reporting. Integrates with the progressr package when available.

Usage

with_progress(expr, name = "Processing", enable = TRUE)

Arguments

expr

Expression to evaluate

name

Character string specifying the name of the operation (default: "Processing")

enable

Logical indicating whether to enable progress reporting (default: TRUE). If FALSE or if progressr is not available, the expression is executed without progress reporting.

Value

The result of evaluating expr.

Details

This function provides a consistent interface for progress reporting across riemtan. Progress handlers can be configured using progressr::handlers().

When enable = TRUE and progressr is installed, users can see progress by calling:

progressr::handlers("progress")  # or "txtprogressbar", "cli", etc.

Examples

if (FALSE) { # \dontrun{
# Enable progress reporting
progressr::handlers("progress")

# Use within a function
result <- with_progress({
  p <- progressr::progressor(steps = 10)
  lapply(1:10, function(i) {
    Sys.sleep(0.1)
    p()  # Signal progress
    i^2
  })
}, name = "Computing squares")
} # }