-
Notifications
You must be signed in to change notification settings - Fork 141
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
Calling a Getter with parameters #14
Comments
If a getter needs to be dynamic then it should be composed of another getter that represents the parameter as state in the system. For example, imagine we have a store mantaining the state of a map of id => ListItem, and a store maintaining the currently selected item id. var selectedItemGetter = [
['listItems'],
['selectedItemId'],
function(items, id) {
return items.get(id)
}
] The idea of using getters is it provides a unit of immediate evaluation for some state in the system. Another way to think about a Getter is it represents a question, in our case "What is the currently selected item?" We can get the answer to that question immediately via If you want to create a function that evaluates a getter based on the parameters it would look like: function getItem(id) {
return flux.evaluate([
['items'],
function(items) {
return items.get(id)
}
])
} |
Could you just use a function to create a getter? I suppose the parameter would reasonably need to be constant for the lifetime of the component where getter is bound function getItem(id) {
return [
['items'],
function(items) {
return items.get(id)
}
]
} |
@jordangarcia In your |
It should live in your |
Is there a solution for this use case?
The text was updated successfully, but these errors were encountered: