Skip to content

Commit 6561d03

Browse files
committed
feat: allow expression to be output of reactive
1 parent 82aeea5 commit 6561d03

17 files changed

+65
-59
lines changed

R/utils.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,21 @@ assert_single_selection <- function(x,
286286
#' @param expr (`expression` or `reactive`) to evaluate on the output of the decoration.
287287
#' When an expression it must be inline code. See [within()]
288288
#' Default is `NULL` which won't evaluate any appending code.
289+
#' @param expr_is_reactive ()
289290
#' @details
290291
#' `srv_decorate_teal_data` is a wrapper around `srv_transform_teal_data` that
291292
#' allows to decorate the data with additional expressions.
292293
#' When original `teal_data` object is in error state, it will show that error
293294
#' first.
294295
#'
295296
#' @keywords internal
296-
srv_decorate_teal_data <- function(id, data, decorators, expr) {
297+
srv_decorate_teal_data <- function(id, data, decorators, expr, expr_is_reactive = FALSE) {
297298
assert_reactive(data)
298299
checkmate::assert_list(decorators, "teal_transform_module")
300+
checkmate::assert_factor(expr_is_reactive)
299301

300302
missing_expr <- missing(expr)
301-
if (!missing_expr) {
303+
if (!missing_expr && !expr_is_reactive) {
302304
expr <- rlang::enexpr(expr)
303305
}
304306

@@ -310,6 +312,8 @@ srv_decorate_teal_data <- function(id, data, decorators, expr) {
310312
req(data(), decorated_output())
311313
if (missing_expr) {
312314
decorated_output()
315+
} else if (expr_is_reactive) {
316+
eval_code(decorated_output(), expr())
313317
} else {
314318
eval_code(decorated_output(), expr)
315319
}

man/srv_decorate_teal_data.Rd

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

man/tm_a_pca.Rd

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

man/tm_a_regression.Rd

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

man/tm_data_table.Rd

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

0 commit comments

Comments
 (0)