-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redux & NuclearJS #216
Comments
Here's why I chose to write Redux instead of using NuclearJS:
With Redux, I can use plain objects, arrays and whatnot for the state. I tried hard to avoid APIs like NuclearJS has a really nice concept of getters but I also felt that it tries to be “too smart” around performance and I didn't want to make this mandatory. Instead, with Redux, you can achieve similar results by using a library like reselect: import React from 'react';
import { createSelector } from 'reselect';
import { connect } from 'redux/react';
const subtotalSelector = createSelector(
[state => state.shop.items],
items => items.reduce((acc, item) => acc + item.value, 0)
);
const taxSelector = createSelector(
[subtotalSelector, state => state.shop.taxPercent],
(subtotal, taxPercent) => subtotal * (taxPercent / 100)
);
const totalSelector = createSelector(
[subtotalSelector, taxSelector],
(subtotal, tax) => { return {total: subtotal + tax}}
);
@connect(totalSelector)
class Total extends React.Component {
render() {
return <div>{this.props.total}</div>
}
}
export default Total; That said, NuclearJS definitely was a big inspiration to me. |
Oh, and of course I had these two other goals in mind that NuclearJS did not satisfy:
|
Thanks for the thorough answer. I've been studying Nuclear's React mixin to understand how I can integrate it into a not-React view layer (in my case, Aurelia). I've also started to take a look at the Collector and CollectorDecorator, but I'm having a time distilling out what's essential. Is there any good documentation or an example about generic view layer integration? BTW, if I get this figured out, I'd be happy to share the approach for your documentation. |
Basically Redux's top-level API is just
These are the only essential parts. |
Okay, good. That's what I was able to deduce from studying Provider and Connector. |
I'm closing as it's not really an issue. |
Thank you @gaearon for the feedback you provided here, was most informative. For those interested, Dan provided more insights on that very topic. |
Both of these projects seems to have a lot of similarities both in philosophy/implementation and mutual respect for one another (one could even see these projects merging one day?). Since I'm "in the market" for a functional, reactive Flux implementation, what would be the things to consider between the two? What would you say are the advantages of Redux over NuclearJS?
The text was updated successfully, but these errors were encountered: