Relative Content

Tag Archive for swiftperformanceswiftuimacrosobservable

How do I bind to a value in an @Observable view model without invalidating all views in SwiftUI?

Migrating your view models from the @ObservedObject protocol to the @Observable macro should reduce the amount of ceremony in your view models (e.g., @Published property wrappers) while increasing the performance of your app as the @Observable macro promises to more intelligent only invalidate the views that need an update. However, when I bind to a string value in an @Observable view model, the opposite seems to happen: