reactiveSource: Create Reactive Source Object

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/reactiveSource.r

Description

Creates a reactive source object that can be used by observable reactive objects created via setShinyReactive or reactive.

Usage

1
2
reactiveSource(id, value = NULL, where = parent.frame(), overwrite = TRUE,
  typed = FALSE, strict_set = c(0, 1, 2), ...)

Arguments

id

character. Name/ID of the reactive source object.

value

ANY. Value of reactive source object.

where

environment. Environment in which to create the object.

overwrite

logical. Only relevant if object already exists. TRUE: overwrite existing value; FALSE: keep currrent value.

typed

logical. TRUE: checks class validity of assignment value specified via value and throws an error if classes do not match or if the class of the assignment value does not inherit from the class of field value .value at initialization; FALSE: no class check is performed. Note that initial values of NULL are disregarded for the class check, i.e. any value overwriting an initial NULL value is valid.

strict_set

numeric. Relevant if typed = TRUE and class mismatch.

  • 0: ignore without warning

  • 1: ignore with Warning

  • 2: stop with error

Further

arguments to be passed to subsequent functions. In particular: setTyped and validateType.

Details

This is a slightly modified version of makeReactiveBinding.

Value

ANY. The value of value.

Author(s)

Janko Thyson janko.thyson@rappster.de

References

http://github.com/Rappster/reactr

See Also

setShinyReactive, reactive

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Not run: 

## Create reactive source //
reactiveSource(id = "x_1", value = 10)
x_1
x_1 <- 20
x_1

## No overwrite //
reactiveSource(id = "x_1", value = 10)
x_1
reactiveSource(id = "x_1", value = 20, overwrite = FALSE)
x_1
## --> as `x_1` already existed with a non-NULL value and `overwrite = FALSE`,
## no overwrite has been performed

##------------------------------------------------------------------------------
## Typed //
##------------------------------------------------------------------------------

## Basics //
## Strict = 0:
(reactiveSource(id = "x_1", value = 10, typed = TRUE))
x_1 <- "hello world!"
x_1
## --> simply ignored 

## Strict = 1:
(reactiveSource(id = "x_1", value = 10, typed = TRUE, strict = 1))
try(x_1 <- "hello world!")
x_1
## --> ignored with warning

## Strict = 2:
(reactiveSource(id = "x_1", value = 10, typed = TRUE, strict = 2))
try(x_1 <- "hello world!")
x_1
## --> ignored with error

## Advanced //
(reactiveSource(id = "x_1", typed = TRUE, from_null = FALSE, strict = 2))
try(x_1 <- "hello world!")

(reactiveSource(id = "x_1", value = 10, typed = TRUE, to_null = FALSE, strict = 2))
try(x_1 <- NULL)

(reactiveSource(id = "x_1", value = 10, typed = TRUE, numint = FALSE, strict = 2))
try(x_1 <- as.integer(10))


## End(Not run)

rappster/reactr documentation built on May 26, 2019, 11:56 p.m.