Skip to content

Commit 9742c56

Browse files
committed
Forward progression properties when relaying a progression
When the progression condition that is to be relayed was created with any arguments, they need to be relayed as well when creating a new progression object in progress_aggregator(). Fixes #126.
1 parent da3dc98 commit 9742c56

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

R/progress_aggregator.R

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ progress_aggregator <- function(progress) {
3131
} else if (type == "reset") {
3232
} else if (type == "shutdown") {
3333
} else if (type == "update") {
34-
progress(child = p)
34+
call_progressor_with_progression(progress, p)
3535
} else {
3636
stop("Unknown 'progression' type: ", sQuote(type))
3737
}
@@ -49,3 +49,24 @@ progress_aggregator <- function(progress) {
4949

5050
fcn
5151
}
52+
53+
#' Rewrite a progression condition and emit using another progressor
54+
#'
55+
#' The progression condition `prog_cnd` is disassembled, the properties that are
56+
#' set by the original progressor are removed and the progression is re-created
57+
#' using the progressor `progr`.
58+
#'
59+
call_progressor_with_progression <- function(progr, prog_cond){
60+
c <- setdiff(class(prog_cond), c("progression", "immediateCondition", "condition"))
61+
arg_list <- unclass(prog_cond)
62+
# Remove all arguments from the list that are not included by the progressor
63+
# (the function generated by a call to the progressor() function) into the
64+
# resulting condition object but are set by the progressor itself. See
65+
# the function that is the return value of progressor() for those arguments.
66+
arg_list$owner_session_uuid <- NULL
67+
arg_list$progressor_uuid <- NULL
68+
arg_list$progression_index <- NULL
69+
arg_list$call <- NULL
70+
arg_list$calls <- NULL
71+
do.call(progr, arg_list)
72+
}

R/progressor.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ progressor <- local({
8686
type = type,
8787
message = message,
8888
...,
89+
# If adding values here that do not come from the parameters of this
90+
# inner function, include them in call_progressor_with_progress() as
91+
# well
8992
progressor_uuid = progressor_uuid,
9093
progression_index = progression_index,
9194
owner_session_uuid = owner_session_uuid,

0 commit comments

Comments
 (0)