Manage multiple and TealDatasetConnector
of the same type.
TealDataConnector.Rd
Class manages TealDatasetConnector
to specify additional dynamic arguments and to
open/close connection.
Super class
teal.data::TealDataAbstract
-> TealDataConnector
Methods
Inherited methods
teal.data::TealDataAbstract$check()
teal.data::TealDataAbstract$check_reproducibility()
teal.data::TealDataAbstract$execute_mutate()
teal.data::TealDataAbstract$get_check()
teal.data::TealDataAbstract$get_check_result()
teal.data::TealDataAbstract$get_code()
teal.data::TealDataAbstract$get_datanames()
teal.data::TealDataAbstract$get_dataset()
teal.data::TealDataAbstract$get_datasets()
teal.data::TealDataAbstract$get_items()
teal.data::TealDataAbstract$is_pulled()
teal.data::TealDataAbstract$mutate_dataset()
teal.data::TealDataAbstract$reassign_datasets_vars()
teal.data::TealDataAbstract$set_check()
teal.data::TealDataAbstract$set_pull_code()
Method new()
Create a new TealDataConnector
object
Usage
TealDataConnector$new(connection, connectors)
Method print()
Prints this TealDataConnector
.
Method set_pull_args()
Set argument to the pull_fun
Method set_ui()
Set connector UI function
Method set_server()
Set connector server function
This function will be called after submit button will be hit. There is no possibility to
specify some dynamic ui
as server
function is executed after hitting submit
button.
Method set_preopen_server()
Set connector pre-open server function
This function will be called before submit button will be hit.
Method pull()
Load data from each TealDatasetConnector
Arguments
con_args
(
NULL
or namedlist
)
additional dynamic arguments for connection function.args
will be passed to eachTealDatasetConnector
object to evaluateCallableFunction
assigned to this dataset. Ifargs
is null than default set of arguments will be used, otherwise call will be executed on these arguments only (arguments set before will be ignored).pull
function doesn't update reproducible call, it's just evaluate function.args
(
NULL
or namedlist
)
additional dynamic arguments to pull dataset.args
will be passed to eachTealDatasetConnector
object to evaluateCallableFunction
assigned to this dataset. Ifargs
is null than default set of arguments will be used, otherwise call will be executed on these arguments only (arguments set before will be ignored).pull
function doesn't update reproducible call, it's just evaluate function.try
(
logical
value)
whether perform function evaluation insidetry
clause
Method launch()
Run simple application that uses its ui
and server
fields to pull data from
connection.
Useful for debugging
Examples
library(magrittr)
#>
#> Attaching package: ‘magrittr’
#> The following objects are masked from ‘package:testthat’:
#>
#> equals, is_less_than, not
random_data_connector <- function(dataname) {
fun_dataset_connector(
dataname = dataname,
fun = teal.data::example_cdisc_data,
fun_args = list(dataname = dataname),
)
}
open_fun <- callable_function(library)
open_fun$set_args(list(package = "teal.data"))
con <- data_connection(open_fun = open_fun)
con$set_open_server(
function(id, connection) {
moduleServer(
id = id,
module = function(input, output, session) {
connection$open(try = TRUE)
return(invisible(connection))
}
)
}
)
x <- teal.data:::TealDataConnector$new(
connection = con,
connectors = list(
random_data_connector(dataname = "ADSL"),
random_data_connector(dataname = "ADLB")
)
)
x$set_ui(
function(id, connection, connectors) {
ns <- NS(id)
tagList(
connection$get_open_ui(ns("open_connection")),
numericInput(inputId = ns("n"), label = "Choose number of records", min = 0, value = 1),
do.call(
what = "tagList",
args = lapply(
connectors,
function(connector) {
div(
connector$get_ui(
id = ns(connector$get_dataname())
),
br()
)
}
)
)
)
}
)
x$set_server(
function(id, connection, connectors) {
moduleServer(
id = id,
module = function(input, output, session) {
# opens connection
connection$get_open_server()(id = "open_connection", connection = connection)
if (connection$is_opened()) {
for (connector in connectors) {
set_args(connector, args = list(n = input$n))
# pull each dataset
connector$get_server()(id = connector$get_dataname())
if (connector$is_failed()) {
break
}
}
}
}
)
}
)
if (FALSE) {
x$launch()
x$get_datasets()
}