Understanding the new Realm 10 Wrappers and SwiftUI

Hi, I recently noticed that Realm 10 introduced some new wrappers, @ObservedResults, @Persisted, and @ObservedRealmObject and I was wondering if there is a tutorial that explains them in more detail to have a better understanding? I see that using these new wrappers minimizes the amount of code used when using Realm since it looks like with this new method you no longer have to call Try? realm.write{} when deleting or saving records. Am I correct to say that using this new set of wrappers would eliminate the need to have a ViewModel or external class to manage the read and write Realm transactions?

In general, can someone please explain what issue does this new set of wrappers try to solve or help with that the native SwiftUI/Combine wrappers (@StateObject and @ObservedObject) couldn’t solve?

Sorry about the silly question.


There is a really good video about SwiftUI best practices with Realm, explaining this new property wrappers.

Documentation about using Realm Database with SwiftUI can be found here https://docs.mongodb.com/realm/sdk/ios/integrations/swiftui/
If you still have doubts about how they work or what are they trying to solve, let know.


Thanks a lot for the video.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.