How do Observables differ from Promises, and how do you avoid subscription leaks?
A Promise represents a single future value and is eager: it starts when created, cannot be cancelled, and has no operators beyond then and catch. An Observable is lazy, emits zero, one or many values over time, can be cancelled with unsubscribe, and composes through RxJS operators.
this.http.get<User[]>('/api/users').pipe(
map(users => users.filter(u => u.active)),
catchError(() => of([])),
).subscribe(users => this.users = users);
Operators like debounceTime, switchMap, distinctUntilChanged and combineLatest make complex async flows declarative. Angular's HttpClient returns cold observables that fire on subscribe, so forgetting to subscribe means no request.
Subscription leaks are a common bug. Prefer the async pipe, which unsubscribes automatically, or use takeUntilDestroyed, takeUntil with a destroy subject, or firstValueFrom for one-off requests. Never leave a bare long-lived subscribe in a component that never cleans up.