Reactive Programming

Sep 02, 2022#cs#reactive

Reactive programming isnโ€™t a new concept; itโ€™s been around for a fairly long time, but its core concepts have made a noticeable comeback over the last decade.

Reactive programming basically means relying on entities emitting elements, subscribing to its changes and reacting to those changes. So, reactive programming saves you from having to re-check states and manually putting conditions in your code. It remarkably reduces the code lines and makes the code cleaner and easier to manage. Most importantly, it manages asynchronous code execution in a very elegant manner owing to its observable-subscriber method.

In contrast to imperative programming, with declarative programming, one can program what the application should do and look like in different states and let it handle itself moving between those states.

In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change.

Reactive programming is a way of doing asynchronous programming. In reactive programming, everything can be a stream of data. One can listen to this data stream and react accordingly.

Reactive systems is a rather abstract term and covers web or iOS apps that exhibit most or all of the following qualities:

  • Responsive: Always keep the UI up to date, representing the latest app state.
  • Resilient: Each behavior is defined in isolation and provides for flexible error recovery.
  • Elastic: The code handles varied workload, often implementing features such as lazy pull-driven data collections, event throttling, and resource sharing.
  • Message-driven: Components use message-based communication for improved reusability and isolation, decoupling the lifecycle and implementation of classes.