Methods
Method new()
Create a new TealDataConnection
object
Usage
TealDataConnection$new(
open_fun = NULL,
close_fun = NULL,
ping_fun = NULL,
if_conn_obj = FALSE
)
Arguments
open_fun
(CallableFunction
) function to open connection
close_fun
(CallableFunction
) function to close connection
ping_fun
(CallableFunction
) function to ping connection
if_conn_obj
optional, (logical
) whether to store conn
object returned from opening
connection
Returns
new TealDataConnection
object
Method finalize()
Finalize method closing the connection.
Usage
TealDataConnection$finalize()
Method is_opened()
If connection is opened
If open connection has been successfully evaluated
Usage
TealDataConnection$is_opened()
Returns
(logical
) if connection is open
Method is_failed()
Check if connection has not failed.
Usage
TealDataConnection$is_failed()
Returns
(logical
) TRUE
if connection failed, else FALSE
Method launch()
Run simple application that uses its ui
and server
fields to open the
connection.
Useful for debugging
Usage
TealDataConnection$launch()
Returns
An object that represents the app
Open the connection.
Note that if the connection is already opened then it does nothing.
Usage
TealDataConnection$open(args = NULL, silent = FALSE, try = FALSE)
Arguments
args
(NULL
or named list
) additional arguments not set up previously
silent
(logical
) whether convert all "missing function" errors to messages
try
(logical
) whether perform function evaluation inside try
clause
Returns
returns self
if successful or if connection has been already
opened. If open_fun
fails, app returns an error in form of
shinyjs::alert
(if try = TRUE
) or breaks the app (if try = FALSE
)
Method get_conn()
Get internal connection object
Usage
TealDataConnection$get_conn()
Returns
connection
object
Method get_open_call()
Get executed open connection call
Usage
TealDataConnection$get_open_call(deparse = TRUE, args = NULL, silent = FALSE)
Arguments
deparse
(logical
) whether return deparsed form of a call
args
(NULL
or named list
) additional arguments not set up previously
silent
(logical
) whether convert all "missing function" errors to messages
Returns
optionally deparsed call
object
Method get_open_error_message()
Get error message from last connection
Usage
TealDataConnection$get_open_error_message()
Returns
(character
)
text of the error message or character(0)
if last
connection was successful.
Method get_preopen_server()
Get shiny server module prior opening connection.
Usage
TealDataConnection$get_preopen_server()
Returns
(function
) shiny server prior opening connection.
Method get_open_server()
Get shiny server module to open connection.
Usage
TealDataConnection$get_open_server()
Returns
(function
) shiny server to open connection.
Method get_open_ui()
Get Shiny module with inputs to open connection
Usage
TealDataConnection$get_open_ui(id)
Arguments
id
character
shiny element id
Returns
(function
) shiny ui to set arguments to open connection function.
Method is_open_failed()
Check if open connection has not failed.
Usage
TealDataConnection$is_open_failed()
Returns
(logical
) TRUE
if open connection failed, else FALSE
Method set_open_args()
Set open connection function argument
Usage
TealDataConnection$set_open_args(args, silent = FALSE)
Arguments
args
(NULL
or named list
) with values where list names are argument names
silent
(logical
) whether convert all "missing function" errors to messages
Returns
(self
) invisibly for chaining.
Method set_preopen_server()
Set pre-open connection server function
This function will be called before submit button will be hit.
Usage
TealDataConnection$set_preopen_server(preopen_module)
Arguments
preopen_module
(function
)
A shiny module server function
Returns
(self
) invisibly for chaining.
Method set_open_server()
Set open connection 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.
Usage
TealDataConnection$set_open_server(open_module)
Arguments
open_module
(function
)
A shiny module server function that should load data from all connectors
Returns
(self
) invisibly for chaining.
Method set_open_ui()
Set open connection UI function
Usage
TealDataConnection$set_open_ui(open_module)
Arguments
open_module
(function
)
shiny module as function. Inputs specified in this ui
are passed to server module
defined by set_open_server
method.
Returns
(self
) invisibly for chaining.
Close the connection.
Usage
TealDataConnection$close(silent = FALSE, try = FALSE)
Arguments
silent
(logical
) whether convert all "missing function" errors to messages
try
(logical
) whether perform function evaluation inside try
clause
Returns
returns (self
) if successful. For unsuccessful evaluation it
depends on try
argument: if try = TRUE
then returns
error
, for try = FALSE
otherwise
Method get_close_call()
Get executed close connection call
Usage
TealDataConnection$get_close_call(deparse = TRUE, silent = FALSE)
Arguments
deparse
(logical
) whether return deparsed form of a call
silent
(logical
) whether convert all "missing function" errors to messages
Returns
optionally deparsed call
object
Method get_close_error_message()
Get error message from last connection
Usage
TealDataConnection$get_close_error_message()
Returns
(character
)
text of the error message or character(0)
if last
connection was successful.
Method get_close_server()
Get shiny server module to close connection.
Usage
TealDataConnection$get_close_server()
Returns
the server function
to close connection.
Method is_close_failed()
Check if close connection has not failed.
Usage
TealDataConnection$is_close_failed()
Returns
(logical
) TRUE
if close connection failed, else FALSE
Method set_close_args()
Set close connection function argument
Usage
TealDataConnection$set_close_args(args, silent = FALSE)
Arguments
args
(named list
) with values where list names are argument names
silent
(logical
) whether convert all "missing function" errors to messages
Returns
(self
) invisibly for chaining.
Method set_close_ui()
Set close connection UI function
Usage
TealDataConnection$set_close_ui(close_module)
Arguments
close_module
(function
)
shiny module as function. Inputs specified in this ui
are passed to server module
defined by set_close_server
method.
Returns
(self
) invisibly for chaining.
Method set_close_server()
Set close-connection 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.
Usage
TealDataConnection$set_close_server(close_module)
Arguments
close_module
(function
)
A shiny module server function that should load data from all connectors
Returns
(self
) invisibly for chaining.
Method clone()
The objects of this class are cloneable with this method.
Usage
TealDataConnection$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
open_fun <- callable_function(data.frame) # define opening function
open_fun$set_args(list(x = 1:5)) # define fixed arguments to opening function
close_fun <- callable_function(sum) # define closing function
close_fun$set_args(list(x = 1:5)) # define fixed arguments to closing function
ping_fun <- callable_function(function() TRUE)
x <- data_connection( # define connection
ping_fun = ping_fun, # define ping function
open_fun = open_fun, # define opening function
close_fun = close_fun # define closing function
)
x$set_open_args(args = list(y = letters[1:5])) # define additional arguments if necessary
x$open() # call opening function
x$get_open_call() # check reproducible R code
#> [1] "data.frame(x = 1:5, y = c(\"a\", \"b\", \"c\", \"d\", \"e\"))"
# get data from connection via TealDataConnector$get_dataset()
if (FALSE) {
x$open(args = list(x = 1:5, y = letters[1:5])) # able to call opening function with arguments
x$close() # call closing function
}