TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Kea – The power of Redux with the simplicity of MobX

60 pointsby mariusandraalmost 8 years ago

9 comments

kasbahalmost 8 years ago
Looks pretty neat. My initial reactions:<p>- I don&#x27;t like the `@kea(...` because it&#x27;s another bit of JS syntax I hadn&#x27;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) =&gt; { 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 =&gt; { actions[name] = value =&gt; { 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>
评论 #14859794 未加载
评论 #14859883 未加载
评论 #14859904 未加载
评论 #14861973 未加载
评论 #14860360 未加载
pavlovalmost 8 years ago
I know it&#x27;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 &quot;actions&quot;, &quot;reducers&quot;, &quot;selectors&quot;, weird functions from something called &quot;redux-saga&#x2F;effects&quot;, a &quot;promise-based timeout&quot; 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.
评论 #14859736 未加载
评论 #14859966 未加载
评论 #14860848 未加载
评论 #14859751 未加载
northalmost 8 years ago
Shameless plug for another take on the same promise: <a href="https:&#x2F;&#x2F;github.com&#x2F;jnorth&#x2F;megalith" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jnorth&#x2F;megalith</a><p>I think most people who are attracted to Redux&#x27;s core principals but want a more opinionated structure will end up gravitating towards mobx-state-tree though.
评论 #14860108 未加载
评论 #14860051 未加载
burntcaramelalmost 8 years ago
I’ve made a lightweight React library influenced by functional setState, and supports async&#x2F;await&#x2F;Promises, extracting values from DOM &#x2F; 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:&#x2F;&#x2F;github.com&#x2F;RoyalIcing&#x2F;react-organism" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RoyalIcing&#x2F;react-organism</a><p>Feedback welcome, here or as issues!
评论 #14861456 未加载
kevincennisalmost 8 years ago
Funny, I always thought of Redux as offering greater simplicity and MobX being more powerful.
评论 #14859983 未加载
Cianticalmost 8 years ago
Is this type-safe? Can it infer the payload type somehow? With MobX you can write type-safe code, and it&#x27;s pretty important in bigger code bases. Redux can be made type-safe but is a bit clunky to use that way.
评论 #14867547 未加载
dpnewmanalmost 8 years ago
The concept expressed in the title matches a desire. Looking forward to checking out and hearing other&#x27;s experiences.
OliverLassenalmost 8 years ago
Why not just use state, which seems like the correct solution to the examples?
评论 #14867559 未加载
33degreesalmost 8 years ago
I have to dig into this but at first glance I like the approach