-
Notifications
You must be signed in to change notification settings - Fork 0
data sharing across components #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Leaning toward the idea of isolated reactives, but this would ideally need a nice interface. Some ideas: Wrapperdata = function() {
list(
x = reactive_value()
)
} Issues with this approach:
New component propertyprops = function() {
list()
} This creates a nice flow of props to data when passing values. E.g. x <- component(
state = function() {
list(
rctv = 1L
)
}, template = function(ns) {
y(data = list(a = self$rctv))
}
)
y <- component() {
data = function() {
list(
a = NULL
)
}
} Also ensures that the state cannot be modified outside the component (because only data can be passed between components) Issues:
|
New component property: state Steps to implementation:
Lines 37 to 49 in 68cca16
Line 52 in 68cca16
|
component data is intentionally isolated from other components so as to encourage comprehensible component hierarchies. however, there are situations where accessing component data externally (and non-hierarchically) is a requirement.
Possible solutions
Hierarchical reactive data
One method of hierarchical and reactive data sharing is via defining reactive values on a top-level component and passing those along to subsequent child components.
E.g.
Barring the eventuality of a long chain of data passing, this has issues with understanding how data may mutate
Event bus
Like how vue does it -- basically just an event emitter
Isolated reactives
Wrapper class around
shiny::reactiveVal
and/orshiny::reactiveValues
that isolates value access from the children of components with data. E.g.stateful object
Object that contains reactive values that can be accessed in any component, similar to vuex
callback (child to parent)
The text was updated successfully, but these errors were encountered: