Skip to content

Commit

Permalink
docs: add note to documentation of teal_transform_module
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Oct 11, 2024
1 parent 310bd07 commit 69bf596
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
12 changes: 0 additions & 12 deletions R/module_teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ srv_teal_data <- function(id,
data_out <- data_module(id = "data")
data_handled <- reactive(tryCatch(data_out(), error = function(e) e))
observeEvent(data_handled(), {
if (inherits(data_out, "reactive.event")) {
# This warning message partially detects when `eventReactive` is used in `data_module`.
warning(
paste(
"srv_teal_data",
"Using eventReactive in teal_transform module server code should be avoided as it",
"may lead to unexpected behavior. See the vignettes for more information ",
"(`vignette(\"data-transform-as-shiny-module\", package = \"teal\")`)."
)
)
}

if (!inherits(data_handled(), "teal_data")) {
is_transformer_failed[[id]] <- TRUE
} else {
Expand Down
17 changes: 17 additions & 0 deletions R/teal_data_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ teal_data_module <- function(ui, server, label = "data module", once = TRUE) {
#' `shiny` module server function; that takes `id` and `data` argument,
#' where the `id` is the module id and `data` is the reactive `teal_data` input.
#' The server function must return reactive expression containing `teal_data` object.
#'
#' The server function definition should not use `eventReactive` as it may lead to
#' unexpected behavior.
#' See `vignettes("data-transform-as-shiny-module")` for more information.
#' @param datanames (`character`)
#' Names of the datasets that are relevant for the module. The
#' filter panel will only display filters for specified `datanames`. The keyword `"all"` will show
Expand Down Expand Up @@ -149,6 +153,19 @@ teal_transform_module <- function(ui = function(id) NULL,
ui = ui,
server = function(id, data) {
data_out <- server(id, data)

if (inherits(data_out, "reactive.event")) {
# This warning message partially detects when `eventReactive` is used in `data_module`.
warning(
paste(
"srv_teal_data",
"Using eventReactive in teal_transform module server code should be avoided as it",
"may lead to unexpected behavior. See the vignettes for more information ",
"(`vignette(\"data-transform-as-shiny-module\", package = \"teal\")`)."
)
)
}

decorate_err_msg(
assert_reactive(data_out),
pre = sprintf("From: 'teal_transform_module()':\nA 'teal_transform_module' with \"%s\" label:", label),
Expand Down
6 changes: 5 additions & 1 deletion man/teal_transform_module.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 69bf596

Please sign in to comment.