var body: some Scene code example
Example: how to compose a custom scene in swiftui
import SwiftUI
@main
struct CardioBotApp: App {
@Environment(\.scenePhase) var scenePhase
@StateObject var store = Store(
initialState: AppState(),
reducer: appReducer,
environment: .live
)
var body: some Scene {
WindowGroup {
RootView().environmentObject(store)
}
.onChange(of: scenePhase) { phase in
switch phase {
case .background:
store.send(.notifications(.startObservers))
case .active:
store.send(.fetch)
default: break
}
}
}
}