...

/

Reactive Programming in Angular

Reactive Programming in Angular

Learn how to enable reactive programming for handling asynchronous data streams and implement a key-logger component using RxJS to illustrate observable usage, emphasizing fromEvent for creating observables from DOM events.

We learned how to create observables and return a stream of events. That’s not all, however. This stream can combine many operations before hitting observers subscribed to it. Just as we can manipulate arrays with methods such as map or filter to transform them, we can do the same with the stream of events emitted by observables. It is a pattern known as reactive programming, and Angular makes the most of this paradigm to handle asynchronous information.

Observer pattern: Core of reactive programming

The observer pattern stands at the core of what we know as reactive programming. The most basic implementation of a reactive script encompasses several concepts that we need to be familiar with:

  • An observable

  • An observer

  • A timeline

  • A stream of events

  • A set of composable operators

Sound daunting? It isn’t. The big challenge here is to change our mindset and learn to think ...