6 Signals: A new approach to reactive programming
This chapter covers
- Problems developers face when working with RxJS in Angular
- Introducing signals, Angular’s new reactive primitive
- Creating new signals and side effects from existing ones
- Signals interoperability with RxJS
In the previous chapter, we talked about reactive programming, how it is useful when working with frontend applications, and how Angular’s commonly chosen library to work with reactivity is RxJS. We covered new approaches and tools Angular provides for working with RxJS, but we did not cover the problems that RxJS itself has that cannot be mitigated simply by adding new tools into the arsenal of Angular developers. In this chapter, let’s focus on these new changes and discuss signals: a new reactive primitive introduced by the Angular core team into the framework itself, which allows us to read values, subscribe to them, derive new values, and execute side effects without having to deal with RxJS at all. Let us see why this new primitive will be helpful and allow us to mitigate various problems with reactivity.
6.1 Why go beyond RxJS?
Previously, we described RxJS as a powerful, flexible, and very capable library for working with reactivity-related logic. So if this library is so mighty, why do we need to introduce another approach? It turns out the vast capabilities of RxJS might actually be a part of the problem in this case. Let’s see what the problems are and then discuss the solutions.