How does MainActor send your data to the main thread? 🧙🏼‍♂️

  Рет қаралды 5,353

Swift and Tips

Swift and Tips

Күн бұрын

Hello guys, Welcome to another video!
In this video, we will learn how to use @MainActor to protect your mutable UI state and always send it to the main thread.
Content:
0:00 - Intro
0:19 - Why UI data must be sent to the main thread?
2:27 - Explaining demo
4:40 - Implementing MainActor
6:41 - Suspension points for actors
8:34 - More about concurrency
------
Source code showed in the video: github.com/pitt500/ActorsDemo...
------
Resources:
* Global actors: github.com/apple/swift-evolut...
* Actors (WWDC21): developer.apple.com/videos/pl...
* Apple: developer.apple.com/documenta...
* swift.org: docs.swift.org/swift-book/Lan...
------
Other videos in the channel:
* Async/await: • Async/Await in Swift |...
* Actors: • How do Actors work in ...
* Async Let: • How to download images...
-----
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

Пікірлер: 10
@Diemermakes
@Diemermakes 3 жыл бұрын
Good stuff! Very concise and well laid out example!
@swiftandtips
@swiftandtips 3 жыл бұрын
Thank you Dan! 😄
@ZainHoda
@ZainHoda Жыл бұрын
Thank you! This is super helpful! I’m trying to make my MVVM code more testable and this should help a lot
@swiftandtips
@swiftandtips Жыл бұрын
Thank you very much @ZainHoda!
@BABEENGINEER
@BABEENGINEER Жыл бұрын
Love how you explained this!
@swiftandtips
@swiftandtips Жыл бұрын
Thanks! 😀
@RomeroSand
@RomeroSand Жыл бұрын
Why not covered case when whole class is @MainActor? Or property marked as @MainActor.
@swiftandtips
@swiftandtips Жыл бұрын
I think is a great topic for a short video, thanks!
@user-mc5tu2nb5x
@user-mc5tu2nb5x 8 ай бұрын
can i have this example github link, am working on chat screen, i will improve my code
@swiftandtips
@swiftandtips 8 ай бұрын
Sure, the link is in the description 👍
Generics in Swift: Protocols with associated types
15:37
Swift and Tips
Рет қаралды 9 М.
How to use Global Actors in Swift (@globalActor) | Swift Concurrency #10
23:50
1,000 Diamonds! (Funny Minecraft Animation) #shorts #cartoon
00:31
toonz CRAFT
Рет қаралды 41 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
How do Actors work in Swift?
19:05
Swift and Tips
Рет қаралды 4 М.
Swift Generics: The Key to Reusable and Flexible Code
23:47
Swift and Tips
Рет қаралды 6 М.
Understanding Actors in Swift
13:11
azamsharp
Рет қаралды 4,5 М.
"any" Keyword and Existential types in Swift
4:59
Swift and Tips
Рет қаралды 9 М.
What is the Sendable protocol in Swift? | Swift Concurrency #11
17:09
Swiftful Thinking
Рет қаралды 11 М.
Какой ноутбук взять для учёбы? #msi #rtx4090 #laptop #юмор #игровой #apple #shorts
0:18
iPhone 15 Pro в реальной жизни
24:07
HUDAKOV
Рет қаралды 502 М.
Better Than Smart Phones☠️🤯 | #trollface
0:11
Not Sanu Moments
Рет қаралды 19 МЛН
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 553 М.
low battery 🪫
0:10
dednahype
Рет қаралды 1,8 МЛН