API adjustments needed
See original GitHub issueThe current API of view, actions and events boils down to this single function signature:
(state, actions, data)
Inside an app call it looks like this:
app({
view(state, actions) {
},
action: {
someAction(state, actions, data)
},
events: {
load(state, actions, root) {
},
render(state, actions, view) {
},
action(state, actions, data) {
},
resolve(state, actions, data) {
},
update(state, actions, data) {
}
}
})
This is usually good enough, but we still have couple of loose ends. How to know which action triggered a state update? How to know the name of the action inside events.resolve? There are workarounds, but nothing good yet.
#339 is a good start, but it means some events signature would change to this:
resolve(state, actions, data, { action, data })
and
update(state, actions, newState, { action, data })
which is not as elegant as I would hope, but if it’s the best we can do then so be it.
I would like to explore alternatives in this thread.
I don’t think there are unlimited possibilities, we just need to make sure we can accommodate action information for resolve and update.
If you have any ideas, please share them. I’ll be adding proposals to this issue as I come up with them.
👋
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (12 by maintainers)
This would involve changing how actions and view work (because we are trying to keep the same signature everywhere). So, while nested destructuring is really nice, I am swaying towards this instead.
But a single object is pretty cool too… 😏
Tough decisions! 😄