Skip to content

Commit

Permalink
Add session$userData
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Dec 15, 2016
1 parent 907b9a9 commit fc91862
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -15,6 +15,8 @@ shiny 0.14.2.9000

* Added ability through arguments to the `a` tag function called inside `downloadButton()` and `downloadLink()`. Closes [#986](https://github.com/rstudio/shiny/issues/986). ([#1492](https://github.com/rstudio/shiny/pulls/1492))

* Added a `userData` environment to `session`, for storing arbitrary session-related variables. Generally, session-scoped variables are created just by declaring normal variables that are local to the Shiny server function, but `session$userData` may be more convenient for some advanced scenarios. ([#1512](https://github.com/rstudio/shiny/issues/1512))

### Bug fixes

* Fixed [#969](ttps://github.com/rstudio/shiny/issue/969): allow navbarPage's `fluid` param to control both containers. ([#1481](https://github.com/rstudio/shiny/pull/1481))
Expand Down
5 changes: 5 additions & 0 deletions R/shiny.R
Expand Up @@ -276,6 +276,9 @@ workerId <- local({
#' This is the request that was used to initiate the websocket connection
#' (as opposed to the request that downloaded the web page for the app).
#' }
#' \item{userData}{
#' An environment for you, the app author, to store whatever data you want.
#' }
#' \item{resetBrush(brushId)}{
#' Resets/clears the brush with the given \code{brushId}, if it exists on
#' any \code{imageOutput} or \code{plotOutput} in the app.
Expand Down Expand Up @@ -692,6 +695,7 @@ ShinySession <- R6Class(
closed = logical(0),
request = 'ANY', # Websocket request object
singletons = character(0), # Tracks singleton HTML fragments sent to the page
userData = 'environment',
user = NULL,
groups = NULL,

Expand All @@ -712,6 +716,7 @@ ShinySession <- R6Class(
self$progressStack <- Stack$new()
self$files <- Map$new()
self$downloads <- Map$new()
self$userData <- new.env(parent = emptyenv())

self$input <- .createReactiveValues(private$.input, readonly=TRUE)
.setLabel(self$input, 'input')
Expand Down
3 changes: 3 additions & 0 deletions man/session.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc91862

Please sign in to comment.