setSessionVariables: Adds variables to a session environment

View source: R/jrc.R

setSessionVariablesR 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 NULL, then variables will be added to all currently active sessions.

makeDefault

If TRUE then, in addition, the specified variables will be added to each new opened session as default ones.

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

getSessionVariable.

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)


jrc documentation built on Aug. 23, 2023, 5:10 p.m.

Related to setSessionVariables in jrc...