Angular anti-patterns #01: Subscribing to every observable
Rxjs is probably the most difficult thing to grasp when starting out with angular. For that reason often times the benefits of rxjs are not used and code like the following is written. @Component({ selector: 'app-subscribing-to-everything-bad', standalone: true, imports: [CommonModule], template: ` <h3>Bad</h3> <p>{{result}}</p> ` }) export class SubscribingToEverythingBadComponent { result: string | undefined; constructor(someService: SomeServiceService) { someService.loadSomething().subscribe((result) => { this.result = result; }); } } The first thing that comes to ones mind when seeing observables would be to subscribe to get the value out of there. Because then you can treat it like any normal variable without needing to learn anything about rxjs. And as in this example this actually works as expected. But lets continue on and we will see why we want to avoid that kind of code. ...