rstudio/shiny — pull request #63 by wch (2012-12-20 06:37:09+00:00)
Title: Wrapper for accessing reactive values without depending on them

The `nonreactive()` function is a wrapper for accessing values without depending on them.

An example:

```R
# Create some values
v <- Values$new()
v$set('x', 1)
v$set('y', 5)
show_x <- reactive(function() v$get('x'))
show_y <- reactive(function() v$get('y'))
show_xy <- reactive(function() v$get('x') * v$get('y'))

# This should only respond to changes of x
observe(function() {
print(paste(
"x:", show_x(),
"y:", nonreactive(show_y()),
"xy:", nonreactive(show_xy()) ))
})

flushReact()
# [1] "x: 1 y: 5 xy: 5"

v$set('x', 2)
flushReact()
# [1] "x: 2 y: 5 xy: 10"

v$set('y', 6)
flushReact() # No output

v$set('x', 3)
flushReact()
# [1] "x: 3 y: 6 xy: 18"
```