Group Group Group Group Group Group Group Group Group

Observe a single CoreData object and update a SwiftUI component

Is this the way to go?

class UserStore: ObservableObject {
  @Published var isPremium: Bool
  
  init(id objectID: NSManagedObjectID,
       in context: NSManagedObjectContext) {
    if let currentUser = try? context.existingObject(with: objectID) as? User {
      self.isPremium = currentUser.isPremium
    } else {
      log.info("No user with \(objectID) exists")
    }
  }
}