-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdependencies.R
57 lines (50 loc) · 1.26 KB
/
dependencies.R
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
52
53
54
55
56
57
# akin to https://github.com/plotly/dash/blob/d2ebc837/dash/dependencies.py
#' Input/Output/State definitions
#'
#' Use in conjunction with the `callback()` method from the [dashR::Dash] class
#' to define the update logic in your application.
#'
#' @name dependencies
#' @author Carson Sievert
#' @param id a component id
#' @param property the component property to use
#' @rdname dependencies
#' @export
output <- function(id = NULL, property = "children") {
structure(
dependency(id, property),
class = c("dash_dependency", "output")
)
}
#' @rdname dependencies
#' @export
input <- function(id = NULL, property = "value") {
structure(
dependency(id, property),
class = c("dash_dependency", "input")
)
}
#' @rdname dependencies
#' @export
state <- function(id = NULL, property = "value") {
structure(
dependency(id, property),
class = c("dash_dependency", "state")
)
}
#' @rdname dependencies
#' @export
event <- function(id = NULL, property = "value") {
structure(
dependency(id, property),
class = c("dash_dependency", "event")
)
}
dependency <- function(id = NULL, property = NULL) {
if (is.null(id)) stop("Must specify an id", call. = FALSE)
list(
id = id,
property = property,
key = paste0(id, ".", property)
)
}