@@ -55,7 +55,6 @@ srv_teal_data <- function(id,
5555 modules = NULL ,
5656 validate_shiny_silent_error = TRUE ) {
5757 checkmate :: assert_string(id )
58- checkmate :: assert_class(data , " reactive" )
5958 checkmate :: assert_class(data_module , " teal_data_module" )
6059 checkmate :: assert_multi_class(modules , c(" teal_modules" , " teal_module" ), null.ok = TRUE )
6160
@@ -96,16 +95,16 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length
9695 data ,
9796 modules = NULL ,
9897 validate_shiny_silent_error = FALSE ) {
99- moduleServer(id , function (input , output , session ) {
100- if (! is.reactive(data )) {
101- stop(" The `teal_data_module` passed to `data` must return a reactive expression." , call. = FALSE )
102- }
98+ checkmate :: assert_string(id )
99+ checkmate :: assert_multi_class(modules , c(" teal_modules" , " teal_module" ), null.ok = TRUE )
100+ checkmate :: assert_flag(validate_shiny_silent_error )
103101
104- data_out_rv <- reactive(tryCatch(data(), error = function (e ) e ))
102+ moduleServer(id , function (input , output , session ) {
103+ data_out_r <- reactive(tryCatch(data(), error = function (e ) e ))
105104
106105 data_validated <- reactive({
107106 # custom module can return error
108- data_out <- data_out_rv ()
107+ data_out <- data_out_r ()
109108
110109 # there is an empty reactive cycle on init!
111110 if (inherits(data_out , " shiny.silent.error" ) && identical(data_out $ message , " " )) {
@@ -116,9 +115,9 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length
116115 need(
117116 FALSE ,
118117 paste(
119- strip_style( data_out $ message ) ,
118+ " Shiny error when executing the `data` module " ,
120119 " Check your inputs or contact app developer if error persists." ,
121- sep = ifelse(identical( data_out $ message , " " ), " " , " \n " )
120+ collapse = " \n "
122121 )
123122 )
124123 )
@@ -130,23 +129,24 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length
130129 validate(
131130 need(
132131 FALSE ,
133- paste (
134- " Error when executing `teal_data_module` passed to `data`: \n " ,
132+ paste0 (
133+ " Error when executing the `data` module: " ,
135134 strip_style(paste(data_out $ message , collapse = " \n " )),
136- " \n Check your inputs or contact app developer if error persists."
135+ " Check your inputs or contact app developer if error persists." ,
136+ collapse = " \n "
137137 )
138138 )
139139 )
140140 }
141141
142142 validate(
143143 need(
144- inherits (data_out , " teal_data" ),
145- paste (
146- " Error: `teal_data_module` passed to `data` failed to return `teal_data` object, returned " ,
147- strip_style(toString(sQuote(class( data_out ))) ),
148- " instead ." ,
149- " \n Check your inputs or contact app developer if error persists. "
144+ checkmate :: test_class (data_out , " teal_data" ),
145+ paste0 (
146+ " Assertion on return value from the 'data' module failed: " ,
147+ checkmate :: test_class( data_out , " teal_data " ),
148+ " Check your inputs or contact app developer if error persists ." ,
149+ collapse = " \n "
150150 )
151151 )
152152 )
@@ -160,7 +160,7 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length
160160 })
161161
162162 output $ shiny_warnings <- renderUI({
163- if (inherits(data_out_rv (), " teal_data" )) {
163+ if (inherits(data_out_r (), " teal_data" )) {
164164 is_modules_ok <- check_modules_datanames(modules = modules , datanames = .teal_data_ls(data_validated()))
165165 if (! isTRUE(is_modules_ok )) {
166166 tags $ div(
@@ -191,8 +191,8 @@ srv_validate_reactive_teal_data <- function(id, # nolint: object_length
191191# ' @return `reactive` `teal_data`
192192# ' @keywords internal
193193.fallback_on_failure <- function (this , that , label ) {
194- checkmate :: assert_class (this , " reactive " )
195- checkmate :: assert_class (that , " reactive " )
194+ assert_reactive (this )
195+ assert_reactive (that )
196196 checkmate :: assert_string(label )
197197
198198 reactive({
0 commit comments