4 ms·
Everytime I see the Flux architecture I wonder what does it bring to the table that a reactive programming library like RxJS or Bacon.js don't? It seems Flux is
by megaman821 12y ago
Everytime I see the Flux architecture I wonder what does it bring to the table that a reactive programming library like RxJS or Bacon.js don't? It seems Flux is just hacking together well-defined concepts in these libraries.
* Stores could use Observables instead of EventEmitter
* Components become Observers by subscribing to Observables which is extremely similar to setting up Listeners.
* Instead of Actions through a Dispatcher, Actions become Proxies (or Subjects in RxJS terms or Buses in Bacon.js terms) that Stores subscribe to and Components push to.
- jlongster 12y agoThe dispatcher really is just a simple pub/sub mechanism. The thing that Flux helps define is how to manage data. We don't have models, but it gives you a coarse structure for your data, with which you can do stuff like data dependencies (derived data), only rerendering part of your UI when parts of your data changes, etc. How events are used within all of this could certainly be re-purposed with Rx (I've repurposed it as channels myself). You are not wrong, but flux is a bit more formalized with a few more things.
- megaman821 12y agoThat makes sense. Just all the code samples I have seen of Flux have most the lines of code dedicated to wiring up events instead of the more interesting things you have mentioned. I think just using either Rx or CSP would make the concepts of Flux clearer.
- jlongster 12y agoI bet if you dug around the internet there are some good examples of that. I've been meaning to show more examples with js-csp, but Rx is pretty popular so I bet there's some examples with that. I bet many of the Flux implementations use a simple event system because that's the lowest common denominator; we're all pretty used to wrapping that in whatever we like anyway. But it does make a little more confusing to look through.
- bsimpson 12y agoThe only reason I haven't moved from Reflux to Rx or Bacon is because I want to see more about Falkor and Relay before deciding on a data management paradigm. Flux feels like a half measure on the way to something more robust; it works well enough, but I bet there's a better solution later this year.
- tlrobinson 12y agoWhat is Falkor?
- bsimpson 12y agoNetflix's data model. They render asynchronously, which lets the render method itself ask Falkor for data it needs and delay rendering until it gets a response. http://www.infoq.com/presentations/netflix-reactive-rest http://www.infoq.com/presentations/netflix-reactive-rest http://techblog.netflix.com/2013/01/reactive-programming-at-netflix.html http://techblog.netflix.com/2013/01/reactive-programming-at-...
- jordanlev 12y agoPerhaps this is what you're looking for: https://github.com/staltz/cycle https://github.com/staltz/cycle ?