DEV Community

Cover image for zip Operator in RxJs
vetriselvan Panneerselvam
vetriselvan Panneerselvam

Posted on

zip Operator in RxJs

Hey, Devs!

Imagine a scenario where you're calling two different observables and need to combine their responses pair by pair. Instead of manually coordinating the emissions, you can use the RxJS zip operator.

Observable A emits every 1 second, while Observable B emits every 3 seconds. The zip operator waits until all input observables have emitted one value before producing an output.

Although Observable A emits multiple values before Observable B emits its first, zip pairs values by their emission order. So, the first value from A is paired with the first value from B, the second with the second, and so on. Values from the faster observable are buffered until the corresponding value from the slower observable becomes available.

Top comments (0)