Skip to content

Commit

Permalink
change assertion to list(ui, server)!
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 3, 2023
1 parent f0c1cc6 commit df885f3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions R/data-transform_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ delayed_data <- function(ui, server, ...) {
)
}

structure(
list(ui = ui, server = server),
x <- list(ui = ui, server = server)
structure(x,
server_args = server_args,
class = "delayed_data"
class = c("delayed_data", class(x))
)
}
9 changes: 5 additions & 4 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ init <- function(data = teal_data(),
footer = tags$p(),
id = character(0)) {
logger::log_trace("init initializing teal app with: data ({ class(data)[1] }).")

if (!inherits(data, c("TealData", "teal_data", "delayed_data"))) {
if (
!inherits(data, c("TealData", "teal_data")) && !is_shiny_module_list(data)
) {
data <- teal.data::to_relational_data(data = data)
}

checkmate::assert_multi_class(data, c("TealData", "teal_data", "delayed_data"))
checkmate::assert_multi_class(data, c("TealData", "teal_data", "list", "delayed_data"))
checkmate::assert_multi_class(modules, c("teal_module", "list", "teal_modules"))
checkmate::assert_string(title, null.ok = TRUE)
checkmate::assert(
Expand Down Expand Up @@ -147,7 +148,7 @@ init <- function(data = teal_data(),
hashables <- mget(c("data", "modules"))
hashables$data <- if (inherits(hashables$data, "teal_data")) {
as.list(hashables$data@env)
} else if (inherits(data, "delayed_data")) {
} else if (is_shiny_module_list(data)) {
# what?
} else if (hashables$data$is_pulled()) {
sapply(get_dataname(hashables$data), simplify = FALSE, function(dn) {
Expand Down
6 changes: 3 additions & 3 deletions R/module_teal_with_splash.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ui_teal_with_splash <- function(id,
# This has the benefit that when filtering the data takes a lot of time initially, the
# Shiny app does not time out.

splash_ui <- if (inherits(data, "delayed_data")) {
splash_ui <- if (is_shiny_module_list(data)) {
data$ui(ns("data"))
} else if (inherits(data, "teal_data")) {
div()
Expand Down Expand Up @@ -69,12 +69,12 @@ srv_teal_with_splash <- function(id, data, modules, filter = teal_slices()) {

# raw_data contains teal_data object
# either passed to teal::init or returned from ddl
raw_data <- if (inherits(data, "delayed_data")) {
raw_data <- if (is_shiny_module_list(data)) {
ddl_out <- do.call(
data$server,
append(
list(id = "data"),
attr(data, "server_args")
attr(data, "server_args") # might be NULL or list() - both are fine
),
quote = TRUE
)
Expand Down
5 changes: 5 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,8 @@ check_filter_datanames <- function(filters, datanames) {
TRUE
}
}


is_shiny_module_list <- function(x) {
is.list(x) && identical(names(x), c("ui", "server"))
}

0 comments on commit df885f3

Please sign in to comment.