Reactive programming-文章解析
数据源(信息源):静态的数组、动态的流;
In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change. This means that it becomes possible to express static (e.g. arrays) or dynamic (e.g. event emitters) data streams with ease via the employed programming language(s),
需要支撑机制
and that an inferred dependency within the associated execution model exists, which facilitates the automatic propagation of the change involved with data flow.
Programming Models and Semantics[edit]
A variety of models and semantics govern the family of reactive programming. We can loosely split them along the following dimensions:
- Synchrony: is the underlying model of time synchronous versus asynchronous?
- Determinism: Deterministic versus non-deterministic in both evaluation process and results (the former does not necessarily imply the latter)
- Update process: callbacks versus dataflow versus actors
Static or Dynamic[edit]
Reactive programming can be purely static where the data flows are set up statically, or be dynamic where the data flows can change during the execution of a program.
The use of data switches in the data flow graph could to some extent make a static data flow graph appear as dynamic, and blur the distinction slightly. True dynamic reactive programming however could use imperative programming to reconstruct the data flow graph.
Higher-order reactive programming[edit]
Reactive programming could be said to be of higher order if it supports the idea that data flows could be used to construct other data flows. That is, the resulting value out of a data flow is another data flow graph that is executed using the same evaluation model as the first.
Similarities with observer pattern[edit]
Reactive programming has principal similarities with the observer pattern commonly used in object-oriented programming. However, integrating the data flow concepts into the programming language would make it easier to express them and could therefore increase the granularity of the data flow graph. For example, the observer pattern commonly describes data-flows between whole objects/classes, whereas object-oriented reactive programming could target the members of objects/classes.