Looks pretty neat. My initial reactions:<p>- I don't like the `@kea(...` because it's another bit of JS syntax I hadn't heard of before. Though I do like decorators in Python, I just feel like I have learned enough of JS syntax to be productive and they seem to keep adding unnecessary stuff.<p>- There is still duplication between the action names and the reducers. When using Redux I now always use these two functions:<p><pre><code> function makeReducer(reducerObject) {
return (state, action) => {
if (Object.keys(reducerObject).includes(action.type)) {
return reducerObject[action.type](state, action.value)
}
return state
}
}
function makeActions(reducerObject) {
const actions = {}
Object.keys(reducerObject).forEach(name => {
actions[name] = value => {
return {type: name, value}
}
})
return actions
}
</code></pre>
So I can just declare a single object of reducers and can infer the action names and creators from that e.g.<p><pre><code> const reducerObject = {
increment(state, value) {
return state + 1
},
decrement(state, value) {
return state - 1
}
}
const reducer = makeReducer(reducerObject)
const actions = makeActions(reducerObject)</code></pre>
I know it's just an example... But the Slider code is ridiculously overwrought.<p>Building this type of image carousel is trivial with just plain HTML+CSS+JS. This example uses "actions", "reducers", "selectors", weird functions from something called "redux-saga/effects", a "promise-based timeout" library AND generator functions to produce the magic ... of switching between images.<p>If someone I work with came up with this code, I would assume that the person is extremely bored with her job and wants to spruce up her résumé with buzzwords.
Shameless plug for another take on the same promise: <a href="https://github.com/jnorth/megalith" rel="nofollow">https://github.com/jnorth/megalith</a><p>I think most people who are attracted to Redux's core principals but want a more opinionated structure will end up gravitating towards mobx-state-tree though.
I’ve made a lightweight React library influenced by functional setState, and supports async/await/Promises, extracting values from DOM / forms easily, pure function actions, animation with requestAnimationFrame, and reloading when props change.<p>I’ve put a lot of effort into providing some good examples (more coming!), and also on keeping it lightweight: core is 1.18KB gzipped.<p><a href="https://github.com/RoyalIcing/react-organism" rel="nofollow">https://github.com/RoyalIcing/react-organism</a><p>Feedback welcome, here or as issues!
Is this type-safe? Can it infer the payload type somehow? With MobX you can write type-safe code, and it's pretty important in bigger code bases. Redux can be made type-safe but is a bit clunky to use that way.