Untitled 2
Untitled 2
especially when dealing with external events or KVO (Key-Value Observing) like window
visibility. However, the code can be simplified.
```swift
@Observable @MainActor
final class AppState {
private let logger = LoggerService(category: "AppState")
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil
#else
false
#endif
}()
cancellables = c
}
}
```
```swift
@Observable @MainActor
final class AppState {
private let logger = LoggerService(category: "AppState")
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil
#else
false
#endif
}()
cancellables = c
}
}
```
For simple property changes within your app's data model, `@Observable` is sufficient.
For external events and complex event processing, continue using Combine.
`@Observable` primarily replaces the property observation aspect of
`ObservableObject` and `@Published`, but it doesn't replace Combine's event handling
and stream processing capabilities. For those cases, you'll still want to use Combine.
For simple property changes within your app's data model, `@Observable` is sufficient.
For external events and complex event processing, continue using Combine.