RxJS

image credits

Reactive programming is an asynchronous programming paradigm concerned with data streams and the propagation of change. — Angular - The RxJS library

I took a closer look into RxJS (Reactive Extensibility Library for JavaScript), which is used in AngularJS. I saw the pipe method and with it you get to map, reduce and filter. This makes the whole thing functional, interesting and nice 🌼.

Reactive programming is nothing new. It is a programming paradigm that is suitable for data flows and has the advantage to react on changes. Normally, when data changes, the results have to be adjusted. With reactive programming, the results adapt themselves, because they are informed about the changes and can react accordingly.

With RxJS an Observable is responsible for this. Together with Observer, Schedulers and Subjects types and map, filter and reduce methods, asynchronous events can be handled like collections.

An observable has the three functions data, error and complete. The RxJS documentation with Observable and Operators is a good place to start.

RxJS is not only suitable for the browser, the article Reactive programming and Observable sequences with RxJS in Node.js describes how RxJS can be used within Node.js and compares the advantage over Promises. There is also a link to a switchMap article: Deep Dive Into The RxJs switchMap Operator - How Does it Work? A Less Well-Known Use Case (selector functions)

Summary

As already mentioned, reactive programming is nothing new. However, it removes the complexity when data changes. This is not only available for JavaScript, it is available for several other programming languages (e.g. Swift, Java, C++, Clojure, Lua) … see ReactiveX Languages.