So, I started writing a guide on how to implement an authorization layer in our apps using Firebase Authentication and before I knew it, I had written

A Whirlwind Tour of Swift Concurrency

submited by
Style Pass
2024-10-26 14:00:04

So, I started writing a guide on how to implement an authorization layer in our apps using Firebase Authentication and before I knew it, I had written well over a thousand words on just the basics of Swift Concurrency. It occurred to me that it might be worthwhile spending some time taking a whirlwind tour of Swift Concurrency so that it might set us up for success as we all begin to adopt Swift 6!

There are a bunch more benefits that we could go over but this is a whirlwind tour after all! Before jumping in to each of these, it's worth getting quick understanding of what Swift Concurrency is.

Let’s take a step back and look at what concurrency means in general. Imagine being at a conference: a keynote speech might be going on in one room, while a hands-on workshop runs simultaneously in another. These events are “concurrent”—happening at the same time but independently of each other.

Now, bring that idea into Swift, and we’re talking about running multiple things side-by-side in our app. Swift Concurrency gives us the tools to manage this easily and safely. In one of my apps, for example, when a user taps "Save" on their profile, two separate tasks kick off: their profile picture is sent to Firebase Storage, and their profile info is saved to Firebase Firestore. Thanks to concurrency, both uploads can happen at the same time. When the image upload completes, the app automatically updates the Firestore document with the image URL—all without making users wait for one upload to finish before the next one starts.

Leave a Comment