Principles of Flux

Unidirectional data flow

Josh Perez
Apr 7, 2015 · 2 min read

A defining characteristic of Flux is that data flows in a single direction. You can think of the data going through a series of transforms, the actions and the stores, before reaching its final destination, the view.

Stores have no setters

Flux stores have no direct setter methods available which means you can only mutate state through the central dispatcher. This leads to an easy to follow mental model on how state is manipulated and where it is initiated. All changes in state begin with a dispatched action.

Inversion of Control

Control lives in the stores which are domain models. The stores are informed by actions and resolve them as appropriate. Nothing outside the store knows how it manages its data helping to keep a clear separation of concerns. Stores may contain collections, singular values, or both.

Single Central Dispatcher

There is a central dispatcher which ensures only one dispatch event goes through at a time. By only having one dispatch happen at a time you’re eliminating cascading events from happening. This makes it simple to reason about what exactly happens when you dispatch an action.

All stores receive the dispatch

Every store has access to the dispatcher and can receive every action. By having all stores receive each action we gain the flexibility to set up dependencies between stores when dealing with derived data. A Flux dispatcher should expose a mechanism to handle this within the store.


Learning Resources

Thanks to Bill Fisher and Dan Abramov for reading a draft of this post.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store