setSessionVariables {jrc} | R Documentation |
Adds variables to a session environment
Description
Each client session in jrc
, gets its own environment that can be accessed only by this
session (or from the outside with the getSessionVariable
function). General purpose
of these environments is to store some session-specific information such as state of the app for
each user. It can also be used to mask variables from the user: if there are two variables with the
same name in the session environment and outside of it, user will not be able to see the latter one.
This function adds new variables to a session environment or changes values of some existing ones.
Usage
setSessionVariables(vars, sessionId = NULL, makeDefault = FALSE)
Arguments
vars |
Named list of variables to be added to a session environment. Names are required and will be used as variable names. |
sessionId |
ID of the session to which variables should be added. Can also be a vector of
multiple session IDs. If |
makeDefault |
If |
Details
This function is a wrapper around method sessionVariables
of class Session
.
If makeDefault = TRUE
, it is also a wrapper around method sessionVariables
of class
App
. The first one changes the current state of the session environment, while the
second specifies default variables for each new session.
See Also
Examples
## Not run:
# to run this example an installed web browser is required
openPage(allowedFunctions = "f", allowedVariables = "res")
m <- 1
f <- function() {v * m}
setSessionVariables(list(v = 1:10, m = 2))
sendCommand("jrc.callFunction('f', [], 'res')", wait = 1)
print(res)
closePage()
## End(Not run)