Angular 41: RxJS Observables Fundamentals
easy⏱ 5 mincourseangular
Push-based streams vs. Promises
A Promise is pull-once: you await it and get exactly one value (or one error), ever. An Observable pushes values to you whenever it wants — synchronously, after a delay, repeatedly, or never. That's what makes RxJS suited to things like user input streams, WebSocket messages, or periodic polling, not just one-off HTTP calls.
const numbers$ = of(1, 2, 3, 4, 5, 6);
numbers$
.pipe(
filter((n) => n % 2 === 0),
map((n) => n * 2),
)
.subscribe((value) => console.log(value));
// logs: 4, 8, 12
pipe() is just a transformation pipeline
Each operator inside .pipe(...) takes the previous stream and returns a new one — nothing runs until the final .subscribe() call, exactly like the cold-observable behavior you saw with HttpClient.