Did you find this preview useful? Are you planning on using async & await in your apps? Let me know in the comments 🚀
@operative30004 жыл бұрын
Do you have a version of this demo in French? Merci
@v_pradeilles4 жыл бұрын
@@operative3000 sorry for the moment I’m not planning to do videos in French
@ganeshpawartrekker2 жыл бұрын
Thank you for sharing knowledge and I am impressed with the way you do it, by comparing old thing and then converting it with new concept makes it simple to understand otherwise teaching new concept directly without giving old way as reference makes it difficult to understand.
@kublaios4 жыл бұрын
That's the second video of yours that I watched and both of them were very fruitful and distinct. Keep up the good work.
@zsoltb70034 жыл бұрын
Thanks for taking the time Vincent. Very helpful!
@Devtherapy4 жыл бұрын
Finally it is happening. I came to iOS and Swift world from C# and I always was missing async/await feature. Finally it will be easy to handle async code without callback hells
@DesperadoAH3 жыл бұрын
I love that you are explaining more advanced features and yet not released 👍, keep up the good work
@lukaszstocki69984 жыл бұрын
Reminds me of "do syntax" in Haskell :) Very cool movie! Waiting for more!
@poluxsaurus14544 жыл бұрын
Hi Vincent, two questions: 1) At 3:26 what keyboard shortcut are you using to get the trailing closure template? and 2) Does calling a function with @asyncHandler prevent blocking of the caller's thread and does that mean that it handles the call in another thread automatically?
@v_pradeilles4 жыл бұрын
1) I just pressed the return key 2) Great question! From what I understand, it will not block the caller's thread. I'm not sure on which queue/thread it gets called, I guess it might have something to do with the new addition "actor classes" to Swift, and I've yet to fully understand that concept.
@poluxsaurus14544 жыл бұрын
@@v_pradeilles re 1) Oh right I didn't remember it would generate trailing closure syntax... thanks
@fredericadda4 жыл бұрын
Wow, super intéressant ! J’avais lu la description de l’évolution, mais c’était assez compliqué à comprendre. Là c’est très pédagogique, bravo!
@v_pradeilles4 жыл бұрын
Merci Fred !
@mickael932604 жыл бұрын
Amazing! Depuis le temps qu'on l'attend sur Swift enfin il arrive
@andybezaire4 жыл бұрын
Thanks, your videos are the best. Could you do this same example but replace the pyramid of doom with a combine publisher? I would love to see that.
@v_pradeilles4 жыл бұрын
That might be an interesting idea for the future! But until then, here’s the short version answer: you want to use the method flatMap() to make sequential calls 🙂
@skanderbahri52743 жыл бұрын
Very helpful thank you
@bscheirman4 жыл бұрын
Really great introduction Vincent! 💯
@KK-pq6lu3 жыл бұрын
Would be very valuable to have a version of this video with same example, but using the now released production version of XCode/Swift to see how it works without the old primitives.
@v_pradeilles3 жыл бұрын
Here it is 👉 Using async / await on iOS 13: everything you need to know! 🚀 kzbin.info/www/bejne/aHiki5ige7J0aMk
@filiplazov58954 жыл бұрын
Great video thank you!
@appalling223 жыл бұрын
nice vid! One thing though - you keep saying the async function blocks, this isn't the case. The function does not block, it suspends, meaning that the thread that *was* executing the function becomes available for other work until the async task is complete. Async gets rid of callback hell and the pyramid of doom, but in this way it also allows concurrency.
@jabquintos4 жыл бұрын
Thank you, Vincent! 🙏
@croco0494 жыл бұрын
Nice intro to the feature ! I hope you didn't scare too many people with the unsafeContinuation API, as people have to keep in mind they'll likely never use this low level primitive in practice (stdlib and Foundation will already provided async API and that's what we'll actually use mostly) One question: how will we handle executing 2 async functions in parallel and waiting for the two at once (think Promise.zip)? Like, in your example, if I want the calls for both first and last name to be sent in parallel and print only when both have returned? (I'm pretty sure that it's something already taken into account in one of the various Concurrency SE proposals but haven't managed to keep track and follow it all, and idk if it's already part of the preview toolchains either?)
@v_pradeilles4 жыл бұрын
Great question! To handle concurrent execution, you can declare your calls using `async let`, then use the corresponding variables inside the same `await` expression and the compiler will handle the low-level background tasks.
@croco0494 жыл бұрын
@@v_pradeilles So async let firstName = await getFirstName(userId: userId) async let lastName = await getLastName(userId: userId) await print("Hello \(firstName) \(lastName)!") ?
@v_pradeilles4 жыл бұрын
@@croco049 precisely!
@christophescholly4 жыл бұрын
Very cool! 👍
@KautilyaSave3 жыл бұрын
Great video.
@palforsberg84323 жыл бұрын
What if you want to retrieve first and last name in parallel? Is that possible?
@v_pradeilles3 жыл бұрын
You indeed can! All the details are in this video 👉 kzbin.info/www/bejne/f6ikgGNsjdlnhbs
@dmitriyobidin60494 жыл бұрын
Right now it looks kinda cumbersome... Especially considering that the beauty of async/await that you shouldn't think about low level details. And with that continuation thing it's just not worth it... Why they didn't make it like in js? Where if you make the function async, it's returning value automatically wrapped with Promise.
@w0mblemania4 жыл бұрын
I agree that it looks janky and inelegant. This keyword and property wrapper proliferation has really gotten out of hand. Swift must look like a frankenstein language to new programmers.
@v_pradeilles4 жыл бұрын
Keep in mind that I used a development build of Swift. When the feature gets released, there will almost certainly be better primitives to create async functions than withUnsafeContinuation 😉
@appalling223 жыл бұрын
It is very similar to how it is in JS (and C# for that matter), it just looks complicated because Vincent's examples are wrapping code that uses completion handlers. The only time you will ever need to do that is when you're making legacy code async, which should be pretty rare. The rest of the time, your code will look basically identical to how it does in JS or C#.
@LouisCognault4 жыл бұрын
Is there cancellation support?
@v_pradeilles4 жыл бұрын
I believe it’s indeed in the works. But of course it would require a bit more code, as then you’d need to deal more explicitly with the implicit background tasks.
@w0mblemania4 жыл бұрын
Thanks for this. I don't like the way Swift is heading with this -- it's super-ugly code to write, and I'm not sure it's any better than the pyramid of doom -- but I'm grateful for the time you've taken to explain it all.
@majidbashir17973 жыл бұрын
did someone remember flutter await and async keywords ? seems likes same functionality to me.
@v_pradeilles3 жыл бұрын
It's indeed a very similar functionality!
@trendz44224 жыл бұрын
It seems like Swift makes more boilerplate code for this 😕