Compare commits

...

4 Commits

Author SHA1 Message Date
Barret Schloerke
550b679e61 Add news item 2020-03-16 10:29:15 -04:00
Barret Schloerke
8ada448c51 add test to make sure the reactive and reactiveVal objects are functions 2020-03-12 17:55:42 -04:00
Barret Schloerke
106ad74d2b add the class 'function' to a reactiveVal object 2020-03-12 17:55:23 -04:00
Barret Schloerke
0a6260259a add the class 'function' to a reactive object 2020-03-12 17:48:41 -04:00
3 changed files with 10 additions and 2 deletions

View File

@@ -19,6 +19,8 @@ shiny 1.4.0.9001
* `getDefaultReactiveDomain()` can now be called inside a `session$onSessionEnded` callback and will return the calling `session` information. ([#2757](https://github.com/rstudio/shiny/pull/2757))
* Added a `'function'` class to `reactive()` and `reactiveVal()` objects. ([#2793](https://github.com/rstudio/shiny/pull/2793))
### Bug fixes
* Fixed [#2606](https://github.com/rstudio/shiny/issues/2606): `debounce()` would not work properly if the code in the reactive expression threw an error on the first run. ([#2652](https://github.com/rstudio/shiny/pull/2652))

View File

@@ -222,7 +222,7 @@ reactiveVal <- function(value = NULL, label = NULL) {
rv$set(x)
}
},
class = c("reactiveVal", "reactive"),
class = c("reactiveVal", "reactive", "function"),
label = label,
.impl = rv
)
@@ -969,7 +969,7 @@ reactive <- function(x, env = parent.frame(), quoted = FALSE, label = NULL,
if (length(srcref) >= 2) attr(label, "srcref") <- srcref[[2]]
attr(label, "srcfile") <- srcFileOfRef(srcref[[1]])
o <- Observable$new(fun, label, domain, ..stacktraceon = ..stacktraceon)
structure(o$getValue, observable = o, class = c("reactiveExpr", "reactive"))
structure(o$getValue, observable = o, class = c("reactiveExpr", "reactive", "function"))
}
# Given the srcref to a reactive expression, attempts to figure out what the

View File

@@ -1,5 +1,11 @@
context("reactivity")
test_that("reactive and reactiveVal are functions", {
expect_s3_class(reactive({1}), "function")
expect_s3_class(reactiveVal(1), "function")
})
test_that("ReactiveVal", {
val <- reactiveVal()