5 RxJS in modern Angular
This chapter covers
- Reactive programming principles
- Using RxJS to build functionality that uses reactive programming
- Unsubscribing from observables in a new way
- Using dependency injection in custom RxJS operators
So far in this book, we have built many features using the different tools that Angular provides. We have already interacted with RxJS several times, mainly when making HTTP calls and handling them in interceptors. However, we can safely say that this is only a tiny part of all the capabilities that RxJS can give us when we are developing frontend applications. In this chapter, we are going to learn about reactive programming and explore RxJS, the first-choice tool for working in this paradigm, its complex (and sometimes sadly overengineered) relationship with Angular, and learn how new modern tools provided by the Angular team help us integrate RxJS seamlessly into our Angular applications. First, let’s understand what RxJS is used for, and what is this “reactive programming” we keep hearing about all the time.