Debian Codegraph @

man/reactiveValues.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/reactives.R
3 \name{reactiveValues}
4 \alias{reactiveValues}
5 \title{Create an object for storing reactive values}
6 \usage{
7 reactiveValues(...)
8 }
9 \arguments{
10 \item{...}{Objects that will be added to the reactivevalues object. All of
11 these objects must be named.}
12 }
13 \description{
14 This function returns an object for storing reactive values. It is similar to
15 a list, but with special capabilities for reactive programming. When you read
16 a value from it, the calling reactive expression takes a reactive dependency
17 on that value, and when you write to it, it notifies any reactive functions
18 that depend on that value. Note that values taken from the reactiveValues
19 object are reactive, but the reactiveValues object itself is not.
20 }
21 \examples{
22 # Create the object with no values
23 values <- reactiveValues()
24
25 # Assign values to 'a' and 'b'
26 values$a <- 3
27 values[['b']] <- 4
28
29 \dontrun{
30 # From within a reactive context, you can access values with:
31 values$a
32 values[['a']]
33 }
34
35 # If not in a reactive context (e.g., at the console), you can use isolate()
36 # to retrieve the value:
37 isolate(values$a)
38 isolate(values[['a']])
39
40 # Set values upon creation
41 values <- reactiveValues(a = 1, b = 2)
42 isolate(values$a)
43
44 }
45 \seealso{
46 \code{\link[=isolate]{isolate()}} and \code{\link[=is.reactivevalues]{is.reactivevalues()}}.
47 }