What if it was only actions?
See original GitHub issueI am rewriting parts of the documentation and currently revisiting the eternal reducers Vs effects.
Why do we need to force users to think about reducers and effects instead of just actions?
If an action returns a promise, we know it’s an effect, otherwise it’s a reducer.
app({
model: {
counter: 0,
waiting: false
},
actions: {
add: model => ({ counter: model.counter + 1 }),
toggle: model => ({ waiting: !model.waiting }),
waitThenAdd: (model, actions) => {
actions.toggle()
return new Promise(resolve => setTimeout(_ => resolve(), 1000))
.then(actions.add)
.then(actions.toggle)
}
},
view: (model, actions) =>
<button
onclick={actions.waitThenAdd}
disabled={model.waiting}
>
{model.counter}
</button>
})
The only drawback is that Promises are not supported in IE11, so obviously we can’t change this right now.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:48 (30 by maintainers)
Top Results From Across the Web
I never worry about action, but only... Winston Churchill - Forbes
I never worry about action, but only about inaction. ... Rightness expresses of actions, what straightness does of lines; and there can no...
Read more >Harm Principle Overview & Examples - Study.com
The harm principle is the principle that only those actions that create harm should be prevented. The British philosopher John Stuart Mill ...
Read more >Assign and Assign only actions - Anapedia - Anaplan
Assign only enables you to assign list items to a parent, but not unassign items that have already been assigned. List items can...
Read more >What are your thoughts on the saying 'there is no right ... - Quora
What they mean is that there are no moral absolutes. Nothing is ever completely right or completely wrong. The rightness or wrongness of...
Read more >Can You Beat Borderlands 2 With ONLY Action Skills?
This video is sponsored by Ridge Wallet: https://www.ridge.com/DIAPERBOOTY Use Code "DiaperBooty" for 10% off your order!
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dodekeract Isn’t that how it works currently? You can just call multiple actions from within an action, don’t return anything.
Ok, it sounds like it is a style thing. I generally prefer callback hell over new language syntax.