Reactive Programming
Reactive Programming
Reactive programming is a paradigm that falls under the domain of declarative programming that is primarily concerned with the propagation of change in data to all its consumers. This paradigm separates variables into static (that do not depend on other variables) and dynamic (whose values derive from computations on other variables). Reactive languages and frameworks provide mechanisms to update dynamic variables when any dependencies change.
Frontend frameworks popularly employ reactive programming, notably React and Vue.js. These frameworks update the view or user interface reactively based on changes to the data in the underlying model.
What is change propagation?
A reactive runtime must keep a directed acyclic graph of dependencies to update all dependents of a variable when its value changes. Each node is a variable in such a graph, and each edge is a unidirectional dependency relationship. Static variables, being independent, do not point to any other variables and are entry points for dependency resolution.
When any variable changes, it immediately taints its dependents as outdated. The runtime must manage these outdated variables and update them, marking their dependents as tainted in the process. As a result, all values pointing to that dependency get updated. Thus a singular change can trigger an avalanche of recomputation. Most reactive runtimes can parallelize these recomputations.
Write clean and secure code with DeepSource
Powerful static analysis that takes 5 minutes to set up and helps you fix code health and security problems on every pull request.