Meaning for action rebinding
ivan-kleshnin opened this issue · 3 comments
So we have now two possible keys: cursors
and actions
@branch({
cursors: {
colors: ['colors']
},
actions: {
add: actions.addColor
}
})
instead of previous API:
@branch({
colors: ['colors']
})
What's the reason behind this action rebinding?
actions.addColor(...)
is shorter than this.props.actions.addColor(...)
and requires no additional declarations. Do we get something by passing vanilla functions through props
?
The binding to the tree through context. Basically it does fn.bind(null, treeFromContext)
. Else you would have to register contextTypes
and so on to get the tree etc. This ensures your actions don't depend on the tree but are passed the tree and so it can be hot reloadable easily.
Got it, thanks.
I would have liked to keep the simple
@branch({
colors: ['colors']
})
but I guess it's more simple to migrate to v2 without and more easily extendable in the future if needed.