79205541

Date: 2024-11-20 01:34:34
Score: 2.5
Natty:
Report link

SwiftUI uses the @StateObject or @ObservedObject property wrapper to observe changes in the ViewModel. To enable this, conform your ViewModel to ObservableObject and use a @Published property to represent the state.

Since you already have a CurrentValueSubject in your ViewModel, you can connect it to a @Published property.

Reasons:
  • No code block (0.5):
  • User mentioned (1): @StateObject
  • User mentioned (0): @ObservedObject
  • User mentioned (0): @Published
  • User mentioned (0): @Published
  • Low reputation (1):
Posted by: codepett.