Search⌘ K
AI Features

Reactive Programming in Angular

Explore reactive programming in Angular by learning to create and manipulate observables with RxJS. Understand the observer pattern and apply it to asynchronous events such as keyboard input. Gain practical skills by building a key logger component that captures and streams keyup events, demonstrating reactive event handling and operator usage.

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 ...