// MARK: Example View struct FeaturesView_SwitchCaseLet: View { let store: Store let delayedAction: AppAction init(store: Store, afterDelaySend action: AppAction) { self.store = store self.delayedAction = action } var body: some View { SwitchStore(store) { CaseLet( state: /AppState.featureOne, action: AppAction.featureOne, then: FeatureView.init(store:) ) CaseLet( state: /AppState.featureTwo, action: AppAction.featureTwo, then: FeatureView.init(store:) ) CaseLet( state: /AppState.featureThree, action: AppAction.featureThree, then: FeatureView.init(store:) ) } .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 3) { ViewStore(store).send(delayedAction) } } } } // MARK: Previews struct ExclusiveFeatureState_Previews: PreviewProvider { static var previews: some View { Group { FeaturesView_SwitchCaseLet( store: Store( initialState: .featureOne(.init(title: "Feature One")), reducer: appReducer, environment: () ), afterDelaySend: .toggleFeatureTwo ) FeaturesView_SwitchCaseLet( store: Store( initialState: .featureTwo(.init(title: "Feature Two")), reducer: appReducer, environment: () ), afterDelaySend: .toggleFeatureThree ) FeaturesView_SwitchCaseLet( store: Store( initialState: .featureThree(.init(title: "Feature Three")), reducer: appReducer, environment: () ), afterDelaySend: .toggleFeatureOne ) } } }