Learning RxJS and functional reactive programming are hard. They have a multitude of concepts, a large API surface, and a fundamental shift in mindset. We will try to make these concepts approachable, the examples clear and easy to explore. First of all, meet the RxJS launchpad.
RxJS is one of the hottest libraries in web development today. Offering a powerful, functional approach for dealing with events and with integration points into a growing number of frameworks, libraries, and utilities, the case for learning Rx has never been more appealing. Couple this with the ability to utilize your knowledge across nearly any language, having a solid grasp on reactive programming and what it can offer seems like a no-brainer.
The basic building blocks of RxJS are observables and observers. Observables are the stream of the data. The observers observe the stream and react to it.
RxJS is based on two design patterns: the Observer and the iterator.
An object implements 2 methods:
It allows the customer of the object to iterate the object’s items. Rx provides many useful operators that create observables.
The main operators are:
- Filter: filter values from the sequence.
- Map: convert each value
- Reduce: aggregate the values.
- flatMap: concatenation of observable.
Learning Rx may be difficult but it is certainly worth the effort! The full list can be found here.