Skip to content

Commit ad5299c

Browse files
authored
feat: support argument rename and clean function body (#888)
# Pull Request - Changes from `teal_reportable` branch at `{ŧeal.report}` - Remove old logic that was defusing the argument
1 parent f0600dc commit ad5299c

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

R/utils.R

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ assert_single_selection <- function(x,
286286

287287
#' Wrappers around `srv_transform_teal_data` that allows to decorate the data
288288
#' @inheritParams teal::srv_transform_teal_data
289-
#' @param expr (`expression` or `reactive`) to evaluate on the output of the decoration.
290-
#' When an expression it must be inline code. See [within()]
289+
#' @inheritParams teal.reporter::`eval_code,teal_report-method`
290+
#' @param expr (`reactive`) with expression to evaluate on the output of the
291+
#' decoration. It must be compatible with `code` argument of [teal.code::eval_code()].
291292
#' Default is `NULL` which won't evaluate any appending code.
292293
#' @details
293294
#' `srv_decorate_teal_data` is a wrapper around `srv_transform_teal_data` that
@@ -296,29 +297,20 @@ assert_single_selection <- function(x,
296297
#' first.
297298
#'
298299
#' @keywords internal
299-
srv_decorate_teal_data <- function(id, data, decorators, expr) {
300+
srv_decorate_teal_data <- function(id, data, decorators, expr, keep_output = NULL) {
300301
checkmate::assert_class(data, classes = "reactive")
301302
checkmate::assert_list(decorators, "teal_transform_module")
302-
expr_is_missing <- missing(expr)
303303

304304
moduleServer(id, function(input, output, session) {
305305
decorated_output <- srv_transform_teal_data("inner", data = data, transformators = decorators)
306306

307-
expr_r <- reactive({
308-
if (is.reactive(expr)) {
309-
expr()
310-
} else {
311-
expr
312-
}
313-
})
314-
315307
reactive({
316308
req(data(), decorated_output())
317-
if (expr_is_missing) {
309+
if (missing(expr)) {
318310
decorated_output()
319311
} else {
320-
req(expr_r())
321-
teal.code::eval_code(decorated_output(), expr_r(), keep_output = TRUE)
312+
req(expr())
313+
teal.code::eval_code(decorated_output(), expr(), keep_output = keep_output)
322314
}
323315
})
324316
})

man/srv_decorate_teal_data.Rd

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)