Reactive programming in Angular
Reactive programming is integral to the Angular framework. Angular heavily relies on Observables (we will explain Observables in detail in the next section) and has the RxJS library built into it to manage Observable data streams in a robust and composable manner. Observables are a reactive design pattern because you have the Observable, or publisher of data, and the subscribers or receivers of the data stream. Subscribers are automatically notified when the Observable emits a new value and can act upon it accordingly.
Observables are utilized in many different aspects within the Angular framework. Here are some examples where you can find Observables within the Angular framework:
- HTTP requests: Within the Angular framework, HTTP requests return Observables by default. HTTP requests in vanilla JavaScript are handled with Promises.
- Router events: The Angular Router class exposes an
events
Observable. With the routerevents
Observable, you...