DispatchGroup fan-out
In a callback-based payments app, you have to build a payment summary after three independent APIs have all finished. Where would you put DispatchGroup's enter and leave so they pair up?
In a callback-based payments app, you have to build a payment summary after three independent APIs have all finished. Where would you put DispatchGroup's enter and leave so they pair up?
Call enter() right before calling each request function, and put defer { group.leave() } on the first line of that request's completion closure so it leaves exactly once whether it ends in success, failure, or cancellation, then build the summary in notify(queue: .main).
ConcurrencyShort answerBasics
When a screen appears you call three APIs in parallel, profile, feed, and notifications…
#dispatchgroup
ConcurrencyShort answerBasics
You have independent pieces of work A, B, and C. C must run only after both A and B have…
#dispatchgroup
ConcurrencyShort answerBasics
A banking app's home screen has to fetch independent account, card, and notification data…
#fanout