| TidyModule | R Documentation |
This is the main class provided by tidymodules and should be the parent of all tidymodules modules. It provides methods for defining input and output communication ports, managing module namespace and many other useful features.
idID of the module.
nameName of the module as generated or provided by the user.
module_nsModule namespace, unique identifier for the module.
parent_nsParent module namespace in case of nested modules.
parent_modReference to parent module in case of nested modules.
pass_portslogical value indicating if the module should pass its ports to any nested modules. This is initialized with the inherit argument of new().
groupGroup name of the module.
createdInitialization time of the module.
orderInitialization order.
ireactive list of input ports.
oreactive list of output ports.
port_nameslist of input and output port names.
reactlist of reactive objects used by the module.
obserlist of observers used by the module.
suspendedboolean indicating whether the module observers are suspended.
new()Create a new tidymodules module.
TidyModule$new( id = NULL, inherit = TRUE, group = NULL, parent = NULL, collision = FALSE )
idUnique Id to assign to the module. Default to a generated Id using module's class and order of initialization.
inheritlogical value indicating if a nested module should inherits the parent's input ports. Default to TRUE
groupModule group name. Added to module's Id to make it unique. Optional
parentParent module. Need to be specified when creating a dynamic nested module. Optional
collisionAllow module id collision. Default to false. Id collision happens when you try to creating the same module (same Id) twice at the same time. Optional
A new TidyModule object.
ns()namespace function used to generate unique Id for HTML elements.
TidyModule$ns(id)
idId of HTML element / shiny input.
A unique string Id.
getSessionId()Get module session Id. This function rely on a shiny output object to find the right session Id.
TidyModule$getSessionId()
The Session Id of the module.
render()Alias to the ui function.
TidyModule$render(...)
...arguments passed to the ui function.
ui()UI function generating the module HTML elements. This function is eventually implemented in the child module to give the module a visual representation. Please note that a module can have many visual representations.
TidyModule$ui(...)
...arguments passed to ui
Empty tagList()
server()server function to be overwritten and called by child module.
TidyModule$server(input, output, session, ...)
inputshiny input.
outputshiny output.
sessionshiny session.
...extra arguments to passed to the server function.
view()Preview the module in a gadget.
TidyModule$view(...)
...extra arguments to passed to the server function.
definePort()Function wrapper for port definition expression.
TidyModule$definePort(x)
xexpression
assignPort()Function wrapper for port assignment expression.
TidyModule$assignPort(x)
xexpression
addInputPort()Add input port function. To be called within definePort function
TidyModule$addInputPort( name = NULL, description = NULL, sample = NULL, input = FALSE, is_parent = FALSE, inherit = TRUE )
nameport name. must be a unique input port name.
descriptionport description.
samplesample dataset consumed by this port. Mandatory!
inputThis argument should be ignored. Only here for backward compatibility.
is_parentIs the port inherited from the parent module.
inheritShould the port be passed to nested module. default to TRUE.
updateInputPort()Function for filling an input port.
Called within the assignPort function
TidyModule$updateInputPort(id = NULL, input = NULL)
idPort name or Id .
inputThe reacive object.
updateInputPorts()This function add a set of input ports to the module.
TidyModule$updateInputPorts(inputs = NULL, is_parent = FALSE)
inputsreactivevalues with the input ports.
is_parentAre the ports from a parent module. Default to FALSE.
getInputPort()Get an input port from the module.
TidyModule$getInputPort(id = 1)
idName or Id of the port.
A module input port. A reactivevalues object with name, description, sample, is_parent and port elements.
iport()Alias to the getInputPort() function.
TidyModule$iport(id = 1)
idName or Id of the port.
A module input port. A reactivevalues object with name, description, sample, is_parent and port elements.
getInputPorts()Get all the input ports as a reactivevalues object.
TidyModule$getInputPorts()
A reactivevalues object.
getInput()Get a input port slot.
TidyModule$getInput(id = 1, w = TRUE)
idName or Id of the port.
wboolean to enable module session check. default to TRUE.
A reactive function.
execInput()Execute an input port slot, that is, the reactive function stored in the port.
The require argument which is TRUE by default allows you disable checking if the port is Truthy.
See shiny::req function.
TidyModule$execInput(id = 1, require = TRUE)
idName or Id of the port.
requireCheck that the port is available.
Output of the reacive function execution.
updateOutputPort()Function for filling an output port.
Called within the assignPort function
TidyModule$updateOutputPort(id = NULL, output = NULL)
idPort name or Id .
outputThe reacive object.
updateOutputPorts()This function add a set of output ports to the module.
TidyModule$updateOutputPorts(outputs = NULL, is_parent = FALSE)
outputsreactivevalues with the output ports.
is_parentAre the ports from a parent module. Default to FALSE.
addOutputPort()Add output port function. To be called within definePort function
TidyModule$addOutputPort( name = NULL, description = NULL, sample = NULL, output = FALSE, is_parent = FALSE )
nameport name. must be a unique output port name.
descriptionport description.
samplesample dataset returned by this port. Mandatory!
outputThis argument should be ignored. Only here for backward compatibility.
is_parentIs the port inherited from the parent module.
getPortName()Utility function that returns a port name from the Id.
TidyModule$getPortName(id = NULL, type = "input")
idPort Id
typePort type, input or output.
Port name.
getOutputPort()Get an output port from the module.
TidyModule$getOutputPort(id = 1)
idName or Id of the port.
A module output port. A reactivevalues object with name, description, sample, is_parent and port elements.
oport()Alias to the getOutputPort() function.
TidyModule$oport(id = 1)
idName or Id of the port.
A module output port. A reactivevalues object with name, description, sample, is_parent and port elements.
getOutputPorts()Get all the output ports as a reactivevalues object.
TidyModule$getOutputPorts()
A reactivevalues object.
getOutput()Get a output port slot.
TidyModule$getOutput(id = 1, w = TRUE)
idName or Id of the port.
wboolean to enable module session check. default to TRUE.
A reactive function.
execOutput()Execute an output port slot, that is, the reactive function stored in the port.
The require argument which is TRUE by default allows you disable checking if the port is Truthy.
See shiny::req function.
TidyModule$execOutput(id = 1, require = TRUE)
idName or Id of the port.
requireCheck that the port is available.
Output of the reacive function execution.
getStore()Function for retrieving the central ModStore.
TidyModule$getStore()
The ModStore object.
countInputPort()Utility function that counts the number of input ports.
TidyModule$countInputPort()
The input ports count.
countOutputPort()Utility function that counts the number of output ports.
TidyModule$countOutputPort()
The output ports count.
use()Alias to the callModule function.
TidyModule$use(...)
...arguments passed to the server function of the module.
callModule()callModule function. Similar to shiny callModule. Used to inject the server logic into the application.
This function don't need the user to provide a namespace Id as a module already knows its identity.
Options provided as arguments will be passed to the server function of the module.
Note that the module reference self might not be the one injected.
TidyModule$callModule(...)
...arguments passed to the server function of the module.
isStored()Function to check if the module is store in the current session.
TidyModule$isStored()
logical value.
isGlobal()Check if the session attached to the module is the global_session.
TidyModule$isGlobal()
logical value.
getSession()Get the current session.
TidyModule$getSession()
A reactivevalues object with the following elements. aid = application Id path = application path sid = session Id count = current module count created = session creation time updated = session update time collection = list of session modules edges = list of connection edges
getGlobalSession()Get the global session.
TidyModule$getGlobalSession()
A reactivevalues object with the following elements. aid = application Id path = application path sid = "global_session" count = session module count created = session creation time updated = session update time collection = list of session modules edges = empty data.frame
doServer()Function interfacing with shiny's callModule.
TidyModule$doServer(...)
...arguments passed to the server function of the module.
getPortDef()Utility function to retrieve a port definition in the form of a list. This is a useful function to learn about a specific port.
TidyModule$getPortDef(type = NULL, id = 1)
typePort type, input or output.
idName or Id of port.
List of the port definition.
print()Module printing function. Print the structure of a module.
TidyModule$print()
MyModule <- R6::R6Class("MyModule", inherit = tidymodules::TidyModule)
m <- MyModule$new()
m
deepClone()Module cloning function. Take care of ports (cloning reactive objects) and nested modules. Note that the Ids/namespace are not changed.
TidyModule$deepClone(o = NULL, i = NULL, s = NULL)
oOptional shiny output.
iOptional shiny input
sOptional shiny input
A cloned module.
reset()This function reset the ports.
TidyModule$reset(o = NULL, i = NULL, s = NULL)
oOptional shiny output.
iOptional shiny input
sOptional shiny input
destroy()This function destroys the module by removing it from the ModStore
and by destroying all its observers. Please note that this function
works properly only if the observers created and used by the module are
added to self$obser.
TidyModule$destroy(deep = FALSE)
deepoptional logical indicating whether to destroy the child modules as well. default to FALSE.
suspend()This function suspends the module's observers.
Please note that this function works properly only if the observers
created and used by the module are added to self$obser.
TidyModule$suspend()
resume()This function resumes the module's observers.
Please note that this function works properly only if the observers
created and used by the module are added to self$obser.
TidyModule$resume()
getShinyInput()Retrieve the shiny input.
TidyModule$getShinyInput()
Shiny input object.
getShinyOutput()Retrieve the shiny output.
TidyModule$getShinyOutput()
Shiny output object.
getShinySession()Retrieve the shiny output.
TidyModule$getShinySession()
Shiny session object.
clone()The objects of this class are cloneable with this method.
TidyModule$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `TidyModule$print`
## ------------------------------------------------
MyModule <- R6::R6Class("MyModule", inherit = tidymodules::TidyModule)
m <- MyModule$new()
m
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.