PromiseKit vs Async/Await (Modern Concurrency)

I was wondering if we can replace PromiseKit with Swift’s modern concurrency?

Hi @efatima and welcome to Forums!

Yes, you absolutely can. And you will find that the code will be much readable after it is all said and done. I advise that you first learn Async/Await (at least the basics) and then come back to your project.

Here is a resource to start with: WWDC 2021: Intro to async/await | Kodeco

@robertomachorro I have actually read the book by Marin Todorov on Modern Concurrency.

The codebase I am working on, is a bit complicated. We have our own observability construct which behaves more or less like Apple’s Combine. It can subscribe to a stream of published updates, subscribes to/ access mutual state and can observe the asynchronous operations and their results.

Now I need to kinda decide between this construct, Apple’s Combine or Swift’s modern concurrency to replace the usage of PromiseKit in our codebase. What are the factors that should be kept in mind while making such decisions?

Since you are doing a conversion, and you seem to have an understanding of published updates, I would with Combine. The blocks from PromiseKit will seem a bit more familiar.

If you are thinking that Combine is not the new and shiny, or outdated because Async/Await, then let me explain that you are comparing the wrong things. Combine is great for events, streams (finite or infinite) and has built in error handling within the stream. It is used by Apple to power SwiftUI.

Async/Await is great for creating a sequence of async calls and decluttering prior threading technology (GCD, etc).

2 Likes

Thanks @robertomachorro for providing your insight on this. I will still keep this open.

1 Like

Thanks a lot for giving me this information. It’s exactly what I needed, and I’m grateful for your assistance

1 Like