This week’s intensive reading article: Exploring data flow solutions for single-page applications

After intensive reading on front-end modularization and syntax-related articles in previous installments, this time we discuss another important topic: data flow. Data flow is as important as engineering, visualization and componentization in the front end. Without the guidance of good data flow framework and ideas, business code tends to be in an unmaintainable state for a long time. When the project continues to add functions, managing data becomes more important.

There was no concept of data flow in the early days of the front end, because the front end was so thin that each page only displayed the requested data and no data flow management was required.

As the front end becomes more and more complex, the framework becomes more and more cohesive, and the data flow scheme is divided and combined, and then divided again. Now, the data flow is gradually unbound from the framework, forming a set of general system for each framework to use.

Although there are many data flow frameworks, they can be basically divided into bidirectional data flow party, one-way data flow party and responsive data flow party, represented by Mobx, Redux and Rxjs respectively. By the way, for CSS, there are also CSS in JS and pure CSS party. The front end is a real pain in the ass. This time we will take a look at the topic shared by Uncle Xu Fei in QConf: Data flow scheme exploration of single page application.

2 Content Summary

This paper mainly introduces the concept of responsive programming, and the viewpoints mentioned are as follows:

  1. ReactiveData encapsulation
  2. Data source, the normalization of data changes
  3. The normalization of local and global states
  4. Fractal thought
  5. Action distributed execution
  6. App level data processing, recommended front-endOrm

Overall, the core idea is to recommend that the data flow be handled internally by components, regardless of whether Redux Mobx or Rxjs is used, or whether these libraries have global management ambitions. If global management is used, it will be mounted globally, but the components will still be managed locally.

Finally, it talks about the advantages of Rxjs and XStream responsive data flow, but does not release the framework, only points out the idea, let some readers itch. But too many “tech gurus” now use “industry conferences” as advertising opportunities or job presentations. It’s better to teach people how to fish than to teach them how to fish, and this article stands out.

3.1 Is responsive data flow the best solution?

I think front-end data flow scheme iteration so far, there is no such thing as object-oriented -> functional -> responsive, such an evolutionary link, different business scenarios have their own advantages.

functional

Represented by Haskell, it is widely used in the financial industry. The possible reason is that finance is very sensitive to the correctness of data. Not only is the function suitable for distributed computing, but more importantly, it makes data computing safer and more reliable without side effects.

In my opinion, the most important reason is that there are few side effects in the financial industry, such as the front-end dealing with Dom every day.

3.2 Fractal thought

The fractal idea is an upgraded version of the congestive component, which also supports the ability of the anaemic component to be controlled externally.

Disadvantages of fractals

For chat rooms or online ides, where there is a lot of global data and a lot of cross-binding, fractal thinking is not a good fit, but pure Redux thinking is more appropriate.

3.4 Where is the processing process from raw data to view data

We recommend putting it in View because we don’t want to add additional stores, but we don’t know if this Store contains a component-specific Store. Business components are recommended to operate with internal data streams, but ultimately view data is stored in the global Store, locally for the component, globally for the project, and this can be supported for specific situations, such as listening for changes in data reused by other components.