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.

Introduction to Facebook's Flux architecture

267 pointsby wayfarer2sabout 10 years ago

22 comments

susi22about 10 years ago
Has anybody in the client side community ever made the connection to rules engines?<p>This flow of logic is awfully close to how a rule engine works. I wonder if people will at some point arrive at it.<p>There isn&#x27;t a whole lot of rules engine in JS. Just nools [1] which is huge. I&#x27;d love to see a very simple forward chaining rule engine + Immutable + React and see how that would work out.<p>My guess is that they aren&#x27;t popular at all because they have the notion of being enterprisey (Drools&#x2F;Jboss). I&#x27;m a big fan of them. They &#x2F;can&#x2F; make life &amp; code very nice and elegant. Maybe somebody writes an JS adapter to clara rules [2].<p>[1] <a href="https://github.com/C2FO/nools" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;C2FO&#x2F;nools</a><p>[2] <a href="https://github.com/rbrush/clara-rules" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rbrush&#x2F;clara-rules</a>
评论 #9096112 未加载
评论 #9099701 未加载
评论 #9096785 未加载
megaman821about 10 years 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&#x27;t? It seems Flux is just hacking together well-defined concepts in these libraries.<p>* Stores could use Observables instead of EventEmitter<p>* Components become Observers by subscribing to Observables which is extremely similar to setting up Listeners.<p>* 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.
评论 #9096445 未加载
评论 #9096548 未加载
评论 #9097330 未加载
sepethabout 10 years ago
Is there a way to get rid of flux boilerplate? I don&#x27;t want to write three different files (a file with actions, another file with constants, and the actual store). For example, I can achieve the same effect with just a simple array and some functions to modify it. I guess I know what the benefit of embracing flux is, but it still looks too much, and I am mostly lazy.
评论 #9095578 未加载
评论 #9095482 未加载
评论 #9097010 未加载
评论 #9095845 未加载
j_sabout 10 years ago
<i>themgt</i> posted the following on the currently trending React thread, sharing what appears to be Flux&#x27;s impending sunset:<p><i>One of the things I didn&#x27;t realize at first was the degree to which Relay&#x2F;GraphQL appear to effectively replace a lot of Flux: <a href="http://facebook.github.io/react/blog/2015/02/20/introducing-relay-and-graphql.html" rel="nofollow">http:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;blog&#x2F;2015&#x2F;02&#x2F;20&#x2F;introducing-...</a><p>Learning Flux sort of seems like learning how to drive stick shift on an &#x27;97 Civic while we wait for the new Tesla to arrive - useful, also a bit annoying. A central store architecture does seem a better match to what Relay will look like though.</i><p><a href="https://news.ycombinator.com/item?id=9094255" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9094255</a><p>edit: fixed link; thanks!
评论 #9095852 未加载
评论 #9097175 未加载
balls187about 10 years ago
&gt; If you&#x27;re like me and you wanted to go further with React, you more than likely would&#x27;ve checked out Flux, had a glance, closed the tab and then reassessed your life as a * developer.<p>This accurately describes my experience yesterday.<p>I think React is quite expressive in it&#x27;s simplicity. Flux on the other hand (even though it&#x27;s good idea), is poorly tooled out.
评论 #9096759 未加载
Bahamutabout 10 years ago
Heh, this post resonates with me - Facebook&#x27;s description of Flux drew a wtf when I first looked at the diagrams on <a href="https://facebook.github.io/flux/docs/overview.html#content" rel="nofollow">https:&#x2F;&#x2F;facebook.github.io&#x2F;flux&#x2F;docs&#x2F;overview.html#content</a> with its weird terminology, but when I did some more further research into it, I found out that I had a lot of very similar patterns with my Angular code.<p>I think they should have chose some better terminology&#x2F;words to describe the overall components, in this case I found the words shutting down my thought process on first glance.
评论 #9095351 未加载
jedirezaabout 10 years ago
I actually think it&#x27;s a good to understand Flux in it&#x27;s purest sense before using a framework. As a learning experiment I created Aqua [<a href="https://github.com/jedireza/aqua" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jedireza&#x2F;aqua</a>]. It was published last week and there&#x27;s a good Q&amp;A thread going on [<a href="https://github.com/jedireza/aqua/issues/2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jedireza&#x2F;aqua&#x2F;issues&#x2F;2</a>].
wnevetsabout 10 years ago
I must be missing something, I see a lot of boilerplate code for minor gain.
goldendaseabout 10 years ago
I find the idea of Flux fascinating, but one thing I&#x27;m a little curious about is where error feedback fits in here... If an AJAX query fails, or something fails validation, how does this information make its way back to the view? If it happens at the action dispatch level, you still have to pass the event through the store? That seems a little... Odd to me.
评论 #9097566 未加载
raziel2pabout 10 years ago
Some of the code examples given here are perfect examples of what I hate about javascript.<p>assign(new Dispatcher(), {methodName: function() {}})<p>Why can&#x27;t I just define a regular class? Even worse, in the following code snippet the arguments seem mismatched with the previous one:<p>assign({}, EventEmitter.prototype, {methodName: function() {}})<p>I can accept this sort of thing if the payoff is high, like getting access to the performance and simplicity of virtual DOM operations in React, but these examples just seem to be to create basic objects.<p>Maybe object-assign is one of the javascript best practices that keep changing every 2 months and I&#x27;m just not paying attention enough? ES6 can&#x27;t come soon enough.
评论 #9097342 未加载
评论 #9095713 未加载
cssmooabout 10 years ago
Perhaps a huge coincidence but I pretty much wrote this framework in C# in 2004 (including rules engine) and was using it for mobile devices (wince&#x2F;symbian). We abandoned it after 4 years for a simple CQRS system with event bus (before Udi&#x2F;Greg went off on it or Fowler formalised it).<p>You know where we are now? Simple JSON REST API with local and remote queues per device updating a document store. All the queues have on receipt and on dispatch handlers attached and that is it. Each of these can modify the state or perform an external action.<p>YMMV but I&#x27;d probably start there first. It&#x27;s much easier than the other two. I might write it up.
andreamazzabout 10 years ago
It&#x27;s always nice to read a writeup on Flux. I would love to hear more about possible isomorphic implementation of the architecture though. Right now besides Fluxible the architecture doesn&#x27;t play well with server side rendering. By the way, shameless plug, I wrote an article on Flux (backed by a Rails API) a while ago, if you&#x27;re interested on the matter: <a href="http://fancypixel.github.io/blog/2015/01/28/react-plus-flux-backed-by-rails-api/" rel="nofollow">http:&#x2F;&#x2F;fancypixel.github.io&#x2F;blog&#x2F;2015&#x2F;01&#x2F;28&#x2F;react-plus-flux-...</a>
评论 #9095592 未加载
giovannibonettiabout 10 years ago
I&#x27;ve run gulp and then got this error, related to CSS&#x2F;SASS:<p>Message: error &#x2F;Users&#x2F;gkbonetti&#x2F;code&#x2F;flux-getting-started&#x2F;public&#x2F;src&#x2F;scss&#x2F;partials&#x2F;_messageBox.scss (Line 3: Invalid CSS after &quot; &amp;&quot;: expected &quot;{&quot;, was &quot;__list {&quot;<p>&quot;__list&quot; may only be used at the beginning of a compound selector.)
评论 #9097322 未加载
评论 #9099928 未加载
评论 #9095632 未加载
评论 #9095627 未加载
dismal2about 10 years ago
Love going through live examples to learn, thanks for sharing!<p>But, I can get it to render (after doing npm&#x2F;bower install then running gulp), but can&#x27;t get it to actually do anything. Everything looks right but clicking around and nothing happens? Anyone else running into this?
评论 #9096878 未加载
Aleman360about 10 years ago
So... a global message bus? That will quickly become spaghetti in a large code base.
评论 #9096673 未加载
评论 #9095914 未加载
nileshtrivediabout 10 years ago
The author of Reflux argues against having a single dispatcher though: <a href="http://spoike.ghost.io/deconstructing-reactjss-flux/" rel="nofollow">http:&#x2F;&#x2F;spoike.ghost.io&#x2F;deconstructing-reactjss-flux&#x2F;</a>
ph0rqueabout 10 years ago
Is there an example using e.g. the rails asset pipeline &#x2F; ruby gems instead of bower?
andylabout 10 years ago
Flux newbies should check out the Reflux implementation.<p><a href="https://github.com/spoike/refluxjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;spoike&#x2F;refluxjs</a><p>One of the best features is that Reflux lets you chain stores to eliminate WaitFor.
评论 #9096463 未加载
评论 #9095659 未加载
harisaminabout 10 years ago
interesting
juancastroabout 10 years ago
This is awesome!
juancastroabout 10 years ago
Testing LibHN 4.0.1? LOL me as well
mlangenbergabout 10 years ago
Don&#x27;t people realize that returning HTML instead of JSON will solve their problem for 80% of the use cases?<p>Looking at Relay&#x2F;GraphQL, the whole picture appears as a gigantic layer of indirection to generate a DOM tree, something you could do serverside 10 layers below.<p>Even &#x27;Components&#x27; are just fragments of HTML, retrieving them in the format you want from the server is much easier. And be honest, replacing a fragment of HTML in the DOM is fast enough for most applications. (don&#x27;t delete form input, though)<p>How does all of this bring Web Development forward? Look at this blog post for example: <a href="http://fancypixel.github.io/blog/2015/01/28/react-plus-flux-backed-by-rails-api/" rel="nofollow">http:&#x2F;&#x2F;fancypixel.github.io&#x2F;blog&#x2F;2015&#x2F;01&#x2F;28&#x2F;react-plus-flux-...</a><p>In 2006, after part 1 you would be done and call it a day. Now I understand that today you need &#x27;realtime&#x27; updating. But the &quot;notification count is off by one&quot; Facebook example is really bad, because instead of doing all the math in JS, one can simply do a GET request to fetch the count from the actual Single Point Of Truth, which is your database.<p>Did this get so complicated because front-end development and back-end development is separated at many places?
评论 #9097004 未加载
评论 #9097378 未加载
评论 #9097593 未加载
评论 #9097337 未加载