SwiftUI Data Flow with the new Observation - simpler SwiftUI code and improved performance in iOS 17

preview_player
Показать описание
In this SwiftUI tutorial, I discuss the new data flow and observation features for iOS 17 and Xcode 15. We explore how these features can simplify your code and improve the performance of your apps. I walk through the process of converting existing code to use the new observation style and highlight potential pitfalls to avoid.
You will learn about the new @Observable macro and the @State and @Bindable property wrappers.
I also demonstrate how to optimize the data flow to only update views when necessary. Overall, the new observation features in Swift UI offer a more streamlined and efficient way to handle data flow in your apps.

I am using Xcode 15 beta 3

Overview
00:00 introduction
02:39 demo project and problem with too many view updates
06:41 converting from observableObject to the new Observation
16:55 demo of Observation
21:41 how to write SwiftUI views for better view redraws
31:10 Summary

If you liked what you learned and you want to see more, check out one of my courses!

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

This is great. I love the diagrams that make the iOS 17 data flow clear and show the difference between pre iOS 17

patgoo
Автор

Thanks for a wonderful tutorial. I liked the focus you provided on refreshing (and the Color.random trick :) ) and it was great to compare the old and new ways. Observation is a breath of fresh air for an old programmer like me - I've had to struggle with c# bindings and NotifyPropertyChanged events and performance was always a visible issue with nested classes. You have a knack for anticipating the questions your audience has for sure :)

eostarman
Автор

Great tutorial. Very well explained. Thank you so much!

tonibuhlmann
Автор

Your tutorials are really straightforward and thoroughly explained. Thanks.

damickillah
Автор

What you want to express is that we can simplify the design pattern of MVVM to the design pattern of VM?😮

穆宁-gh
Автор

It’s more efficient and easier to preview if you pass book.title into the View init in instead of book

indiekiduk
Автор

Great video, helped me. I did the migration of my app (around 30k lines of code) to the new Observation framework yesterday evening and I realised that Binding is probably meant to stay. At least, I currently don't see how Binding can be completely replaced.

jeyhey
Автор

Although this is another good tutorial Prater, it still relies on NavigationView, which is to be deprecated.

Right now I am trying to meld both your NavigationStack video (A Full Tour of NavigationStack, NavigationLink and navigationDestination - SwiftUI tutorial 2022) and this workflow of keeping views updates and when to use persistent data.

JemmaGuaney
Автор

I have a rather “intricate” app and I find it so difficult to manage the states. For example, what if I have a class that has an array of structs as one of the properties and this struct has another property that should be an observable class (because some of its properties are going to be edited by the user)? Should everything become an observable class…?

Desertbynight
Автор

🏆Outstanding! This inspired me to convert my swift playground project but now I'm stuck figuring how to add a "minimum deployments" section to the general tab of the projects file 😢

AlanRick
Автор

Great content, keep it coming please.

dmitrygolovin
join shbcf.ru