How to use Continuations in Swift (withCheckedThrowingContinuation) | Swift Concurrency #7

preview_player
Показать описание
Continuations are a super-handy addition to the Swift language that allows us to convert code that is not created for an asynchronous context into code that can easily be integrated into our async/await methods. In this video, we will look at withCheckedThrowingContinuation and convert some @escaping closures into our Swift Concurrency code. This is perfect for SDKs and APIs that are not yet updated for Swift Concurrency!

🤙 WELCOME BACK 🤙

Рекомендации по теме
Комментарии
Автор

Wonderful explanations, much thanks ^^

Ysid
Автор

Thank you Nick. I saw this in a codebase recently and had zero idea of what it means or does. You are a life saver.
Anyway, it is the "get rid of this nonsense" for me at 20:56, Lmao!

ObinnaAguwa-nx
Автор

These videos and your whole channel is amazing. Simple, straightforward explanation about something that actually IS complicated! Thanks for your work!

lucagfc
Автор

Happy New Year and thank you for these tutorials. It's Jan 1st 7am where am at and your videos are the first thing I'm watching starting 2023.

krutomjer
Автор

after a long time, I come back to your videos, u look good my g!!! I like ur hairstyle

amith
Автор

Awesome video on how to reuse legacy code with our new async model. Thank you!

josemanuelortizsanchez
Автор

Thanks for breaking this stuff down so well. It's finally starting to gel a bit in my mind. I have several functions with completion handlers in project that are called in sequence (ex: sequential alerts and completion handlers after animations) that will really benefit from this type of conversion to more linearly readable code. Much appreciated!

richardhasson
Автор

You are beautiful!
Thanks for your work❤️
Hugs from Ukraine 🇺🇦

ПогореловИван-жр
Автор

As always fantastically simple representation of what tends to be a confusing topic. On thing I might do for readabilty is use two guards instead of if, else if, else. But this is very much a personal preference thing.

lincolndickerson
Автор

It's amazing video again!!
You always let us easily to know the complicated things~~
thanks you so much

光莒
Автор

In the previous videos - when we add the downloaded images to the [UIImage] array - why is it not necessary to do it in the main thread (Main Actor) ?
Truly fantastic and educational videos BTW.

nithyavasudevan
Автор

is basically alternative to using Combine?
Interesting playlist but i remember that on Intermediate Playlist you said that Combine is the future of Swift. Is Concurrency actually better than Combine? When to use each of them? Is the performance difference that significant?
Great playlist, tho. Learning a lot of new cool stuff!
One more question. What do you think about Reactive Programming with f.ex RxSwift? Do you use that? Is it worth putting time on learing RxSwift?

maciusessa
Автор

Very nice series here. I'm learning a lot. Your GetData function at 5:23 could actually be a one liner like this:

func getData(url: URL) async throws -> Data {
try await URLSession.shared.data(from: url, delegate: nil).0
}

tokero
Автор

amazing content, straight to the point and simple examples

tbgnb
Автор

Would it be a good idea to make a continuation from the Data.write(to:) function which may take some time?

danielcrompton
Автор

Amazing video! I was really struggling getting my head around continuations. Just one quick question, I've read somewhere that after resuming a continuation we should set it to nil, is that true? And if so, why? Thanks!

fernandoivanperezruiz
Автор

Hi Nick thanks for the amazing content and your great explanation skills.
Is there a way to convert a function that its completion handler returns twice? for example in AWS AppSync the completion handler returns the cached data then returns again the updated data from backend I tried withCheckedContinuation but I got an error that it must resume only once. Thanks :)

moalsamman
Автор

Nick, are you able to do a video on Swift metatypes?

jasondhindsa
Автор

Amazing content! Thanks for sharing that with us :-)

MauricioChavesDias
Автор

Hi Nick. Quick question, func getHeartImageFromDatabase() async -> UIImage doesn't use .resume() at the end. Could you tell me why is that ? Great content as always, thank you for your work.

obsessed