1. Explain map, filter, tap, and finalize with a simple example.
map transforms values, filter drops values that don’t match a condition, tap is for side-effects like logging without changing the value, and finalize runs once when a stream completes or errors (e.g., to hide a loader).
this.loading = true;
this.api.getUsers().pipe(
map(users => users.filter(u => u.active)),
tap(active => console.log('Active:', active.length)),
finalize(() => this.loading = false)
).subscribe({ next: u => this.users = u, error: e => this.error = e });