7

Facebook announced that it's using the architecture they call Flux to develop their projects.

It consists of a single direction dataflow, and concepts like a Dispatcher, Stores and Actions (well described here).

This is their illustration of how the pieces glue together:

Views ---> (actions) ----> Dispatcher ---> (registered callback) ---> Stores -------+
Ʌ                                                                                   |
|                                                                                   V
+-- (Controller-Views "change" event handlers) ---- (Stores emit "change" events) --+

My question is: Is that a new idea? Is it a application architecture used before? Is it a "best practice" borrowed from another language/framework?

The purpose of this question is to deepen the knowledge about the architecure which have been gaining lots of attention lately, and seem very different from the MV* pattern most developers I know have been working with.

4

I believe that is an abstraction of CQRS (Command Query Responsibility Segregation) http://www.codeproject.com/Articles/555855/Introduction-to-CQRS

enter image description here

  • 3
    Could you elaborate on that statement and link? How are they similar? What is CQRS? – user40980 Jun 3 '15 at 11:19
  • @MichaelT See Dan Abramov's explanation here: medium.com/@dan_abramov/the-case-for-flux-379b7d1982c6#d70f – mjhm Sep 1 '15 at 1:10
  • Yes, the Flux design pattern has a lot in common with the CQRS and its principles can be used also at the backend to deal with complex state management. – Anderson Marques Dec 21 '18 at 10:37
3

I don't recall seeing the specific Views -> Dispatcher -> Stores architecture before, but the more general concept of a "flow" has been around a while, as they mention in the article you linked:

This structure allows us to reason easily about our application in a way that is reminiscent of functional reactive programming, or more specifically data-flow programming or flow-based programming, where data flows through the application in a single direction — there are no two-way bindings.

There's a ton of information and some existing implementations out there if you search those terms. I've done some functional reactive programming with elm. The restrictions it forces on you are sometimes difficult to work within, but those restrictions also make it very difficult to get into an inconsistent state or create weird update cycles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.