What Is Reactive Programming?
Reactive programming (Reactive programming (Rx)) originally came from Functional Reactive Programming (FRP) in functional languages. Later it became popular in mainstream languages with the addition of the Reactive Extension to the Microsoft .Net Framework.
- Several popular approaches have been taken when creating reactive programming languages. A specification of a proprietary language specific to various domain constraints. These constraints are typically characterized by real-time, embedded computing, or hardware descriptions. Another approach involves the specification of a universal language, which includes support for reactivity. Other methods are used in the definition and use programming libraries or embedded domain-specific languages that can react alongside or on top of the programming language. Norms and the use of these different methods lead to language proficiency tradeoffs. Generally, the more restricted the language, the more its associated compilers and analysis tools can inform the developer (for example, when the execution analysis program can actually be executed in real time). Specific functional transactions may lead to a deterioration in the universal applicability of language.
- Various models and semantics determine the scope of reactive programming. We can loosely split them along the following dimensions:
- Synchrony: Is it the basic model of time synchronization and asynchronous?
- Determinism: Certainty and non-determinism in the assessment process and results.
- Update process: callback and data flow with participants.
Reactive programming operation
- You can fuse reactive programming with ordinary imperative programming. In such an example, an imperative program runs on a reactive data structure. This setup is similar to constrained imperative programming; however, when constrained imperative programming manages two-way constraints, reactive imperative programming manages one-way data flow constraints.
Reactive Programming Object Oriented
- Object-oriented reactive programming (OORP) is a combination of object-oriented programming and reactive programming. Perhaps the most natural way to do this combination is as follows: objects are not methods and domains, but objects are automatically re-evaluated when other reactions they depend on are modified.
- Here is a description of the A = X + Y introduction example using JavaScript and jQuery:
X: <input type = "text" id = "X" /> <br /> Y: <input type = "text" id = "Y" /> <br /> A: <span id = "A"> </ span>
function setA () {// A = X + Y as integers var A = parseInt ($ ('# X'). val ()) + parseInt ($ ('# Y'). val ()); $ (' #A '). Text (A);} setA (); // for initial value of A $ (' # X, # Y '). Css (' cursor ',' pointer '). Click (function () { // by reaction to a click at X or at Y ... var obj = $ (this); obj.val (parseInt (obj.val ()) + 1); // updates X or Y setA (); / / updates A});
- If the OORP programming language retains its imperative approach, then it also belongs to the category of imperative reactive programming.