Book Image

Flux Architecture

By : Adam Boduch
Book Image

Flux Architecture

By: Adam Boduch

Overview of this book

Whilst React has become Facebook’s poster-child for clean, complex, and modern web development, it has quietly been underpinned by its simplicity. It’s just a view. The real beauty in React is actually the architectural pattern that handles data in and out of React applications: Flux. With Flux, you’re able to build data-rich applications that engage your users, and scale to meet every demand. It is a key part of the Facebook technology stack that serves billions of users every day. This book will start by introducing the Flux pattern and help you get an understanding of what it is and how it works. After this, we’ll build real-world React applications that highlight the power and simplicity of Flux in action. Finally, we look at the landscape of Flux and explore the Alt and Redux libraries that make React and Flux developments easier. Filled with fully-worked examples and code-first explanations, by the end of the book, you'll not only have a rock solid understanding of the architecture, but will be ready to implement Flux architecture in anger.
Table of Contents (21 chapters)
Flux Architecture
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Enforcing unidirectional data flow


If new data only enters the system via action payloads delivered by the dispatcher and our store data is immutable, we have a unidirectional data-flow. This is the goal, so the questions is, how do we enforce this? Can we simply say that our store data is immutable and be done with it? Well, that's something to shoot for, absolutely, but there's more to it than that.

In this section, we'll address the concept of data flowing in unintended directions, and what causes this to happen. We'll then consider the notion of having too many stores and not enough actions as contributors to dysfunctional data-flows. Finally, we'll examine some techniques that we can utilize to make our store data immutable.

Backwards, sideways, and leaky data flow

Flux architectures have a unidirectional data-flow—data enters from the left and exits on the right. This is easy to visualize as a flow that moves forward. What are some of the ways this can go wrong then? Take backwards flow...