rstudio/shiny — pull request #445 by wch (2014-04-22 03:04:56+00:00)
Title: Add str.reactivevalues

Fixes #443. It turns out there isn't a problem at all with accessing reactive objects outside of a reactive context. The issue is that `[[.reactivevalues` and `$.reactivevalues` have been defined to have special behavior, so when `str()` tries to print out `x$impl`, R thinks that it's trying to access one of the reactive values, when in reality it's trying to access impl from the underlying representation.

The output now looks like this:

```
> str(reactiveValues(x=1))
List of 1
$ impl:Reference class 'ReactiveValues' [package "shiny"] with 6 fields
..$ .label : chr "reactiveValues4554"
..$ .values :
..$ .dependents :
..$ .namesDeps :Reference class 'Dependents' [package "shiny"] with 1 fields
.. ..$ .dependents:Reference class 'Map' [package "shiny"] with 1 fields
.. .. ..$ .env:
.. .. ..and 22 methods, of which 10 are possibly relevant:
.. .. .. clear, containsKey, get, initialize, keys, mset, remove, set, size, values
.. ..and 14 methods, of which 2 are possibly relevant:
.. .. invalidate, register
..$ .allValuesDeps:Reference class 'Dependents' [package "shiny"] with 1 fields
.. ..$ .dependents:Reference class 'Map' [package "shiny"] with 1 fields
.. .. ..$ .env:
.. .. ..and 22 methods, of which 10 are possibly relevant:
.. .. .. clear, containsKey, get, initialize, keys, mset, remove, set, size, values
.. ..and 14 methods, of which 2 are possibly relevant:
.. .. invalidate, register
..$ .valuesDeps :Reference class 'Dependents' [package "shiny"] with 1 fields
.. ..$ .dependents:Reference class 'Map' [package "shiny"] with 1 fields
.. .. ..$ .env:
.. .. ..and 22 methods, of which 10 are possibly relevant:
.. .. .. clear, containsKey, get, initialize, keys, mset, remove, set, size, values
.. ..and 14 methods, of which 2 are possibly relevant:
.. .. invalidate, register
..and 19 methods, of which 7 are possibly relevant:
.. .setLabel, get, initialize, mset, names, set, toList
- attr(*, "readonly")= logi FALSE
- attr(*, "class")= chr "reactivevalues"
```

And if it's wrapped in another object, it has proper indenting:

```
> str(list(foo = reactiveValues(x=1)))
List of 1
$ foo:List of 1
..$ impl:Reference class 'ReactiveValues' [package "shiny"] with 6 fields
.. ..$ .label : chr "reactiveValues4560"
.. ..$ .values :
.. ..$ .dependents :
.. ..$ .namesDeps :Reference class 'Dependents' [package "shiny"] with 1 fields
.. .. ..$ .dependents:Reference class 'Map' [package "shiny"] with 1 fields
.. .. .. ..$ .env:
.. .. .. ..and 22 methods, of which 10 are possibly relevant:
.. .. .. .. clear, containsKey, get, initialize, keys, mset, remove, set, size, values
.. .. ..and 14 methods, of which 2 are possibly relevant:
.. .. .. invalidate, register
.. ..$ .allValuesDeps:Reference class 'Dependents' [package "shiny"] with 1 fields
.. .. ..$ .dependents:Reference class 'Map' [package "shiny"] with 1 fields
.. .. .. ..$ .env:
.. .. .. ..and 22 methods, of which 10 are possibly relevant:
.. .. .. .. clear, containsKey, get, initialize, keys, mset, remove, set, size, values
.. .. ..and 14 methods, of which 2 are possibly relevant:
.. .. .. invalidate, register
.. ..$ .valuesDeps :Reference class 'Dependents' [package "shiny"] with 1 fields
.. .. ..$ .dependents:Reference class 'Map' [package "shiny"] with 1 fields
.. .. .. ..$ .env:
.. .. .. ..and 22 methods, of which 10 are possibly relevant:
.. .. .. .. clear, containsKey, get, initialize, keys, mset, remove, set, size, values
.. .. ..and 14 methods, of which 2 are possibly relevant:
.. .. .. invalidate, register
.. ..and 19 methods, of which 7 are possibly relevant:
.. .. .setLabel, get, initialize, mset, names, set, toList
..- attr(*, "readonly")= logi FALSE
..- attr(*, "class")= chr "reactivevalues"
```