In SwiftUI's ViewModel class that are @Observable, is it necessary to annotate private fields as @ObservationIgnored?
I'm not sure if adding @ObservationIgnored to these fields will get performance gains, since there are no SwiftUI structs referencing these fields because they're private. However, I'd like to know what's the recommended approach here?
While this might not seem obvious for the example below, however, sometimes I have private fields that are changing pretty frequently. For these frequently changed fields, I think the performance gains will be larger.
Example:
@Observable
class UserProfileViewModel {
var userName: String?
var userPhoneNumber: String?
private var isFetchingData = false
}
vs
@Observable
class UserProfileViewModel {
var userName: String?
var userPhoneNumber: String?
@ObservationIgnored private var isFetchingData = false
}