combineLatest vs forkJoin vs zip in RxJS
IntermediateAngular interview questionBy UIRound, updated 3 December 2026
Short answer
All three combine several observables into one stream of arrays, but they emit at different times. forkJoin waits for every source to complete, then emits once with each source's last value, like Promise.all. combineLatest waits until every source has emitted once, then emits again whenever any of them emits, with the latest value from each. zip pairs values by position: first with first, second with second.
The one-table answer
forkJoin |
combineLatest |
zip |
|
|---|---|---|---|
| First emission | When all sources have completed | When all sources have emitted at least once | When every source has an n-th value |
| How often | Once | On every emission of any source | Once per complete set of n-th values |
| Values used | Last value of each | Latest value of each | The n-th value of each |
| Completes | Right after its one emission | When all sources complete | When a completed source has no buffered values left |
| A source never completes | Never emits | Fine, keeps emitting | Fine, as long as it keeps emitting |
| A source completes without a value | Completes, emits nothing | Completes, emits nothing | Completes, emits nothing |
| Any source errors | Errors, unsubscribes the rest | Errors, unsubscribes the rest | Errors |
| Closest analogy | Promise.all |
A spreadsheet formula over live cells | Array.zip or pairing two lists |
All three accept an array of sources. forkJoin and combineLatest also accept an object, and then emit an object with the same keys.
One timeline, three results
Two sources:
a$emits1at 1s,2at 3s, then completes at 4s.b$emits"x"at 2s,"y"at 5s, then completes at 6s.
| Time | combineLatest([a$, b$]) |
zip([a$, b$]) |
forkJoin([a$, b$]) |
|---|---|---|---|
| 1s | nothing (b$ has no value) |
nothing | nothing |
| 2s | [1, "x"] |
[1, "x"] |
nothing |
| 3s | [2, "x"] |
nothing (b$ has no 2nd value) |
nothing |
| 5s | [2, "y"] |
[2, "y"], then completes |
nothing |
| 6s | completes | done | [2, "y"], then completes |
zip completes at 5s because a$ has completed and its buffer is empty, so no third pair can ever form. combineLatest completes only when both sources have completed.
forkJoin: parallel requests that finish
forkJoin is the tool for "load these in parallel, render when all are back". Angular's HttpClient observables emit once and complete, so they fit perfectly.
import { forkJoin } from "rxjs";
forkJoin({
user: this.http.get<User>(`/api/users/${id}`),
orders: this.http.get<Order[]>(`/api/users/${id}/orders`),
}).subscribe(({ user, orders }) => {
this.user = user;
this.orders = orders;
});The object form gives you named results instead of positions. If either request fails, forkJoin errors and unsubscribes from the other request. If you want partial results, the way Promise.allSettled works, put catchError(() => of(null)) on each request before passing it in.
combineLatest: derived state from live inputs
combineLatest suits values that keep changing, such as filters, a sort order and a product list, where any change should recompute the view.
import { combineLatest, map } from "rxjs";
const visible$ = combineLatest([products$, filter$, sort$]).pipe(
map(([products, filter, sort]) => applyFilterAndSort(products, filter, sort)),
);Nothing is emitted until all three have a value. If filter$ is a plain Subject that has not emitted yet, the view stays empty. Give such inputs a starting value with startWith(...) or use a BehaviorSubject, which always has one. Values that a source emits before the others are ready are dropped, except the last one.
zip: pairing by position
zip is rarer. It suits streams that line up one to one: a list of requests and a list of their labels, or a sequence of moves and a sequence of timestamps. If one source is faster, zip buffers its values until the other catches up, so an endless fast source paired with a slow one grows its buffer without limit. For "latest value from another stream when this one fires", use withLatestFrom instead.
To implement the exact completion rules from scratch, try Implement RxJS combineLatest, withLatestFrom, forkJoin, zip and race. The same three ideas over async iterables are in Implement combineLatest, zip and withLatestFrom over async iterables.
Pass an array, not separate arguments
combineLatest(a$, b$) and forkJoin(a$, b$) still work in RxJS 7, but that rest-parameter form has been deprecated since RxJS 6.5, and the RxJS 7 source marks it for removal in v8. Write combineLatest([a$, b$]) and forkJoin([a$, b$]), or use the object form.
Common follow-up questions
Why does my forkJoin never emit?
One source never completes. Typical culprits are a BehaviorSubject, a store selector, valueChanges on a form or a route parameter stream. forkJoin waits for completion, so add take(1) or first() to those sources, or use combineLatest if you want updates.
Why does my combineLatest emit twice for one change?
Two of its inputs come from the same source. When that source emits, each derived input emits in turn, and combineLatest emits once per input, the first time with one new value and one old. Derive both values in a single map from the shared source, or add debounceTime(0) if you can accept an async hop.
What is the difference between forkJoin and Promise.all?
They behave the same for single-value sources: wait for all, fail fast on the first error. The difference is that forkJoin takes the last value of each source, so a source that emits several times only contributes its final value, and it is lazy: nothing runs until you subscribe.
combineLatest or withLatestFrom?
combineLatest emits when any input emits. source$.pipe(withLatestFrom(other$)) emits only when source$ emits, reading other$'s latest value. Use it for "on submit, read the current form value".
What if I pass an empty array?
forkJoin([]) and combineLatest([]) complete immediately without emitting. Guard against that when the array comes from data, or the subscriber's next handler never runs.
Mistakes to avoid
Using
forkJoinwith a source that never completes and waiting foreverUsing
combineLatestwith aSubjectthat has no starting value and wondering why nothing rendersExpecting
forkJointo keep emitting after the first result; it emits onceUsing
zipwith sources that emit at very different rates, which grows its buffersPassing sources as separate arguments, which is deprecated in RxJS 7
Sources
Practise it in code
Interviewers rarely stop at the definition. These questions open in an editor with tests.
- Implement RxJS
combineLatest,withLatestFrom,forkJoin,zipandracewith exact completion rulesHard55 min - Implement
combineLatest,zipandwithLatestFromover async iterablesHard60 min - Implement a lazy
zip()andzipLongest()that close unfinished iteratorsMedium30 min - Implement an
Observablewith operators and teardownHard50 min - Implement RxJS
BehaviorSubject,ReplaySubject,AsyncSubjectandshareReplaywithrefCountMedium45 min