BACK
Reference · 29

zip

Emits once every source has its nth position ready.

Signature

zip([a$, b$, ...]): Observable<[A, B, ...]>

Marble diagram

a:        --a----b---|
b:        ----1-----2|
result:   ----[a,1]--[b,2]|

What it does

Waits for the nth next from each source, emits them together as a tuple, then moves to n+1. Like a zipper — synchronizing by index.

When to use

Paired data: keys + values, names + avatars, two processes stepping in lockstep.

Gotcha

If one source emits faster than another, the extra values are buffered in memory. For differing speeds, combineLatest is usually better.

See also

combineLatest, forkJoin, pairwise

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...