Daily iOS
Concurrency

Combine zip vs combineLatest

Write a Combine pipeline that sends two different network requests (user profile, account list) at the same time and emits a result once, only when both have completed. Would you use zip or combineLatest, and why?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Use zip to pair two one-shot requests. zip matches the nth value from each upstream and emits once, only when both have arrived, while combineLatest re-emits the latest combination whenever either side changes after both have emitted once, so the meaning differs. Zip the profile and accounts publishers, map them into a dashboard model, receive on main, and sink.

Share a question