Modern state management

Modern state management begins with Flux, which is not a library or framework. It is more a pattern that is different from the traditional MVC pattern.

In a large-scale application that uses MVC, you can easily end up with something like the following:

Figure 11.1: Unmanaged data flows (source: https://www.youtube.com/watch?v=nYkdrAPrdcw)

As you can see, the data that flows between Models and Views is unmanageable. It would be hard to try to figure out the data change flow.

In Flux, data flows in the same direction, as you can see in Figure 11.2:

Figure 11.2: Unidirectional data flow in Flux (source: https://www.youtube.com/watch?v=nYkdrAPrdcw)

When users interact with a component on a page, which is called a view, the View will propagate an action through a central Dispatcher to the Store that holds the application's data, and the changes made in the store will be updated to all the associated views accordingly.

As you can see, the data flow is much simpler and easier to follow in Flux than in MVC.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.111.179