Async/Await in Swift | Comparison vs Closures and Combine Framework

  Переглядів 8,989

Swift and Tips

Swift and Tips

День тому

Hello guys, Welcome to another video!
Today we will implement one of the new features introduced for Swift 5.5: Asynchronous functions. This will be possible by using the async/await syntax, let's see how we can refactor a code fully of closures and complicated error handling.
This demo is based on the previous video showing SwiftUI 3.0, I recommend you to check it out: • What's new in SwiftUI ...
Content:
0:00 - Intro
0:31 - State of the art
1:21 - Asynchronous code using closures
8:25 - A lot of boilerplate code!
9:19 - What is async/ await solving?
10:11 - Async/Await in action
18:28 - Is it the end of Combine?
19:29 - Outro
------
Source code showed in the video: github.com/pitt500/swift-and-...
------
Resources:
* Meet async/await in Swift: developer.apple.com/videos/pl...
* Async/await proposal: github.com/apple/swift-evolut...
* Async functions with Combine: www.swiftbysundell.com/articl...
------
Other videos in the channel:
* State management in SwiftUI: • State Management in Sw...
* UIKit in SwiftUI: • UIKit in SwiftUI
* Generics: • Generics
* The power of Combine: • The power of Combine
* Never type in Swift & SwiftUI: • Never Type in SwiftUI:...
-----
Don't forget to subscribe to the channel, like it, and follow me on social media:
Twitter:
/ swiftandtips
/ pitt500
Finally, ask me for a video you would like to see next 😄!
Credits:
- Music by Wataboi from pixabay.com/
- Video edited with LumaFusion

КОМЕНТАРІ: 31
@markph0204
@markph0204 2 роки тому
...However, in some cases the system could sent it to another thread.
@swiftandtips
@swiftandtips 2 роки тому
Hi Mark, you are right, actors protect your data against data races by multiple threads. What I meant is that with actos you can have a better control over what is getting access to your resource, but your point is absolutely valid. Sorry if that wasn’t clear enough.
@swiftandtips
@swiftandtips 2 роки тому
By the way, I also talked about Actors in this video ukposts.info/have/v-deo/cJqnqH56j4BlsKs.html 😃
@markph0204
@markph0204 2 роки тому
@@swiftandtips All good - I could have written my reply better too. ... but to ensure only one thread accesses the actor at one time. :-)
@ColeDano
@ColeDano 2 роки тому
Thanks for going over the old way and the new async await way. Super helpful for me.
@rungxanh2901
@rungxanh2901 2 роки тому
Thank you so much for the great demo Pitt 🤟🏻
@swiftandtips
@swiftandtips 2 роки тому
Thank you @Joe 😃!
@gacastro
@gacastro 2 роки тому
Another excellent video that puts a new concept in context of current options which I find very helpful. 👍
@swiftandtips
@swiftandtips 2 роки тому
Thank you Gonzalo 😄🙌🏻
@user-fc8hd6kh2f
@user-fc8hd6kh2f 10 місяців тому
brilliante, magnifico! excellent explanation of the topic !!!! you are a genius
@swiftandtips
@swiftandtips 10 місяців тому
Thank you 🙏🙏
@Leopugpiano
@Leopugpiano 2 роки тому
hey man, great content keep going!
@swiftandtips
@swiftandtips 2 роки тому
Thank you @Leonardo! 😄
@rodspears
@rodspears 2 роки тому
Great video! I really liked the use of three difference approaches to the problem. async/wait looks much clean than Combine.
@swiftandtips
@swiftandtips 2 роки тому
Thank you @Rod! And I agree with you, async/await is much cleaner 👌
@roman3249
@roman3249 Рік тому
Awesome 🔥
@robmontesinos
@robmontesinos 2 роки тому
Excellent video. What would be your guess as to when this feature will be available for production?
@swiftandtips
@swiftandtips 2 роки тому
Hi @Roberto, once “iPhone 13” is announced, iOS 15 will be released along with Xcode 13 and there is when officially we can start using it for production. Normally this happens at most early Octubre. Thank you for your support! 😋
@user-qk7iq4ph4y
@user-qk7iq4ph4y 6 місяців тому
This is a fantastic video, but I have one question. What would occur if I made an asynchronous request that took a while to receive a response, and in the meantime, I navigated back to the previous screen and wanted to cancel the unfinished request? How could I manage that situation?
@swiftandtips
@swiftandtips 6 місяців тому
Great question Vitor, I would suggest to take a look to this post: www.hackingwithswift.com/quick-start/concurrency/how-to-cancel-a-task
@jemmytech5474
@jemmytech5474 6 місяців тому
great tutorial. Keep it up. can you help me to create a sandBox tester account ? I am getting an error of "This email address is not available for use as an Apple ID. You may already have an Apple ID associated with this address. Please try again or sign in using your existing Apple ID."
@swiftandtips
@swiftandtips 6 місяців тому
Hi Jemmy, I would need more context to guide you on this. What have you found on google?
@indomitabletr1834
@indomitabletr1834 11 місяців тому
Should we cancel async await functions if we push another screen etc?
@swiftandtips
@swiftandtips 11 місяців тому
Great question, if it’s inside a task modifier then the operation will be cancelled.
@abdulwahabkhan4316
@abdulwahabkhan4316 10 місяців тому
Did you ever use "debounce" or "semaphore" in your network calls. ??
@swiftandtips
@swiftandtips 10 місяців тому
Some time ago 👍
@vaibhavshiledar8213
@vaibhavshiledar8213 2 роки тому
Hello sir, please make next tutorial on Method swizzling in swift
@swiftandtips
@swiftandtips 2 роки тому
Hi @Vaibhav, I will investigate about it. Thank you for the idea! 😁
@jackdanyal4329
@jackdanyal4329 2 роки тому
Swift 15.5 and let us introduce Channels 😂
How do Actors work in Swift?
19:05
Swift and Tips
Переглядів 3,7 тис.
Your Brain 🧠 on Swift Concurrency - iOS Conf SG 2023
30:38
iOS Conf SG
Переглядів 7 тис.
Мама забыла взять трубочку для колы
00:25
Даша Боровик
Переглядів 528 тис.
Experimenting with async & await in Swift
15:50
Vincent Pradeilles
Переглядів 9 тис.
Download JSON from API in Swift with Combine | Continued Learning #23
34:43
Swiftful Thinking
Переглядів 25 тис.
iOS 15 Async Await JSON Fetching AsncImage Main Actors
31:28
Lets Build That App
Переглядів 14 тис.
Intro to async/.await in Rust
13:57
Let's Get Rusty
Переглядів 81 тис.
How to get started with Swift Concurrency 🧵 (Beginner Tutorial)
2:13:35
Vincent Pradeilles
Переглядів 4 тис.
Swift Closures Explained - The ONLY video you'll ever need!
17:33
Get Swifty
Переглядів 3,9 тис.
Samsung UE40D5520RU перезагружается, замена nand памяти
0:46
Слава 100пудово!
Переглядів 3,9 млн
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
ПОЛГОДА строгого режима для Lenovo Legion 5 pro. Чем может обернуться обычный ремонт ноутбука?
31:47
ААНТ КОНТАКТ Сервис по ремонту техники в ЕКБ, СПБ
Переглядів 34 тис.
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Переглядів 904 тис.
поворотний механізм для антени
0:17
Lazeruk
Переглядів 14 тис.