Observable fundamentals for Angular
What an observable actually is, and where Angular itself already relies on them before you write a line of RxJS.
Observable fundamentals for Angular
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- An observable is a sequence of values delivered over time — think of it as a stream that can emit zero, one, or many values, rather than a container holding one value right now.
- Nothing happens with an observable until something subscribes to it — defining one is inert, exactly the same relationship an `<ng-template>` has to being rendered.
- Angular's own `HttpClient`, `Router`, and reactive forms are all observable-based under the hood — this isn't a separate library bolted on, it's how large parts of the framework itself already work.
A sequence over time, not a single value right now
A promise represents one eventual value — it resolves once, and it’s done. An observable represents something broader: a sequence of values, delivered over time, that can emit zero, one, or indefinitely many times. A mouse-click stream is a natural observable — every click is a new emission, for as long as you keep listening — in a way that has no sensible promise equivalent at all. That broader shape is the entire reason RxJS exists in Angular: plenty of real things an app deals with (user input over time, a WebSocket feed, a sequence of HTTP retries) genuinely aren’t “one value, eventually” — they’re a stream.
Defining one does nothing — subscribing is what starts it
const numbers$ = new Observable<number>((subscriber) => {
subscriber.next(1);
subscriber.next(2);
subscriber.complete();
});
numbers$.subscribe((value) => console.log(value)); // only now does anything run
This should feel familiar: it’s the same relationship an <ng-template> has to
actually being rendered, or a pipe’s transform has to actually running.
Creating the observable above executes none of the function passed to
new Observable(...) — nothing happens until .subscribe() is called. Each
subscription independently triggers that function to run again, from the start.
This is precisely why calling an HttpClient method and never subscribing to
the result means the request is never sent at all — a very common early mistake,
and a direct consequence of observables being lazy by default.
Angular already runs on observables, before you write any RxJS yourself
This isn’t a separate library you’re opting into — it’s already underneath
large parts of the framework you’ve been using throughout this roadmap.
HttpClient’s methods all return observables. The Router’s navigation events
and route parameters are observable-based. Reactive forms expose a control’s
value changes as an observable stream (valueChanges). The async pipe, a few
lessons back, exists specifically because so much of what a template needs to
display arrives via exactly this mechanism.
That’s the practical reason this lesson comes before the deeper RxJS material that follows it: you’ve already been consuming observables, through the async pipe, without necessarily registering that’s what was happening. The next few lessons go from “here’s what an observable is” to “here’s how to transform, combine, and manage the streams Angular itself is already handing you.”
Cold vs. hot, briefly
One distinction worth knowing now, even before it’s load-bearing: most
observables you create yourself (including what HttpClient returns) are
cold — the underlying work (the actual HTTP request) only happens when
something subscribes, and a second subscription triggers a second, independent
execution. A hot observable is already producing values regardless of
whether anything’s subscribed — a stream of DOM click events is a natural
example. This distinction is exactly why piping the same observable through
| async twice risked a double-subscription bug in the previous lesson — a cold
observable genuinely re-runs its underlying work per subscription, which hot
observables don’t.
This lesson’s video builds the Observable/Observer/Subscription relationship directly; the linked “deeper” video from the same channel is a second, simple-explanation pass at the same fundamentals if anything above needs a second angle.
Check yourself
If you call `http.get('/api/users')` and never subscribe to the result, does the HTTP request actually get sent?
No. `HttpClient` methods return observables, and an observable does nothing until subscribed to — defining the request isn't the same as executing it. This is a common beginner surprise coming from `fetch`, which fires the request the moment you call it, with no separate subscription step.
What's the difference between an observable that can emit many values over time and a promise?
A promise resolves exactly once (or rejects once) and is done. An observable can emit zero, one, or an unbounded sequence of values over its lifetime — a click-event stream, for instance, naturally emits every time a click happens, which a promise has no way to represent at all.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.