Let's say I have a class to represent a user:
class User : Equatable, Codable, ObservableObject
{
@Published var ID: String = ""
@Published var username: String = ""
@Published var firstName: String = ""
@Published var lastName: String = ""
@Published var EMail: String = ""
@Published var phoneNbr: String = ""
@Published var avatarURL: String = ""
@Published var mediaServiceID: String = ""
@Published var validated: Bool = false
...
}
I also have a controller ("viewmodel") to broker interactions between SwiftUI views and the User. It contains a User object as:
@MainActor class UserManager : ObservableObject
{
@Published var user: User
...
}
And finally of course the view, into which I pass the UserManager upon initialization:
struct StartupView: View
{
@ObservedObject var userMgr: UserManager
...
}
Changing published members of the User embedded in UserManager does not trigger a UI refresh. That strikes me as broken, since everything is published. Is it expected behavior?