How to use MainActor with Observable Macro in SwiftUI | Swift Concurrency #19
🚨🚨🚨 UPDATE: In newer versions of Swift, you can now restrict @Observable to an actor! This resolves the problems discussed in this video. Just add @MainActor AFTER @Observable...
@Observable @MainActor class MyViewModel {
}
🚨🚨🚨
Discover how to combine the Observable Macro with MainActor for effective threading in SwiftUI apps. This tutorial guides you through managing UI updates and data changes on the main thread, utilizing the Observable Macro and MainActor to ensure smooth and responsive app performance. Ideal for SwiftUI developers seeking to optimize multithreading and data handling.
🤙 WELCOME BACK 🤙
WEBSITE: https://www.swiftful-thinking.com
DISCORD: https://discord.gg/tSzJGx9RwE
GITHUB: https://github.com/SwiftfulThinking/
SAY THANKS: https://www.buymeacoffee.com/nicksarno
0:00 Observable MainActor
01:58 Welcome back!
03:13 Background
05:52 RIP: Purple warning
06:49 Problem
09:09 Solutions
11:14 Wrapping up