- Welcome migrated to ReducerProtocol - snapshot test fixed
This commit is contained in:
parent
53011ff4c8
commit
410de3bfa2
|
@ -8,6 +8,7 @@ typealias AppViewStore = ViewStore<AppState, AppAction>
|
|||
|
||||
typealias AnyRecoveryPhraseDisplayReducer = AnyReducer<RecoveryPhraseDisplayReducer.State, RecoveryPhraseDisplayReducer.Action, AppEnvironment>
|
||||
typealias AnyRecoveryPhraseValidationFlowReducer = AnyReducer<RecoveryPhraseValidationFlowReducer.State, RecoveryPhraseValidationFlowReducer.Action, AppEnvironment>
|
||||
typealias AnyWelcomeReducer = AnyReducer<WelcomeReducer.State, WelcomeReducer.Action, AppEnvironment>
|
||||
|
||||
// MARK: - State
|
||||
|
||||
|
@ -31,7 +32,7 @@ struct AppState: Equatable {
|
|||
var internalRoute: Route = .welcome
|
||||
var sandboxState: SandboxState
|
||||
var storedWallet: StoredWallet?
|
||||
var welcomeState: WelcomeState
|
||||
var welcomeState: WelcomeReducer.State
|
||||
|
||||
var route: Route {
|
||||
get { internalRoute }
|
||||
|
@ -61,7 +62,7 @@ enum AppAction: Equatable {
|
|||
case respondToWalletInitializationState(InitializationState)
|
||||
case sandbox(SandboxAction)
|
||||
case updateRoute(AppState.Route)
|
||||
case welcome(WelcomeAction)
|
||||
case welcome(WelcomeReducer.Action)
|
||||
}
|
||||
|
||||
// MARK: - Environment
|
||||
|
@ -416,10 +417,13 @@ extension AppReducer {
|
|||
environment: { _ in SandboxEnvironment() }
|
||||
)
|
||||
|
||||
private static let welcomeReducer: AppReducer = WelcomeReducer.default.pullback(
|
||||
private static let welcomeReducer: AppReducer = AnyWelcomeReducer { _ in
|
||||
WelcomeReducer()
|
||||
}
|
||||
.pullback(
|
||||
state: \AppState.welcomeState,
|
||||
action: /AppAction.welcome,
|
||||
environment: { _ in WelcomeEnvironment() }
|
||||
environment: { $0 }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,28 +8,16 @@
|
|||
import Foundation
|
||||
import ComposableArchitecture
|
||||
|
||||
typealias WelcomeReducer = Reducer<WelcomeState, WelcomeAction, WelcomeEnvironment>
|
||||
typealias WelcomeStore = Store<WelcomeState, WelcomeAction>
|
||||
typealias WelcomeViewStore = ViewStore<WelcomeState, WelcomeAction>
|
||||
typealias WelcomeStore = Store<WelcomeReducer.State, WelcomeReducer.Action>
|
||||
|
||||
// MARK: - State
|
||||
|
||||
struct WelcomeState: Equatable {}
|
||||
|
||||
// MARK: - Action
|
||||
|
||||
enum WelcomeAction: Equatable {
|
||||
case debugMenuStartup
|
||||
}
|
||||
|
||||
// MARK: - Environment
|
||||
|
||||
struct WelcomeEnvironment { }
|
||||
|
||||
// MARK: - Reducer
|
||||
|
||||
extension WelcomeReducer {
|
||||
static let `default` = WelcomeReducer { _, _, _ in
|
||||
struct WelcomeReducer: ReducerProtocol {
|
||||
struct State: Equatable {}
|
||||
|
||||
enum Action: Equatable {
|
||||
case debugMenuStartup
|
||||
}
|
||||
|
||||
func reduce(into state: inout State, action: Action) -> ComposableArchitecture.EffectTask<Action> {
|
||||
return .none
|
||||
}
|
||||
}
|
||||
|
@ -39,13 +27,12 @@ extension WelcomeReducer {
|
|||
extension WelcomeStore {
|
||||
static var demo = WelcomeStore(
|
||||
initialState: .placeholder,
|
||||
reducer: .default,
|
||||
environment: WelcomeEnvironment()
|
||||
reducer: WelcomeReducer()
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Placeholders
|
||||
|
||||
extension WelcomeState {
|
||||
static let placeholder = WelcomeState()
|
||||
extension WelcomeReducer.State {
|
||||
static let placeholder = WelcomeReducer.State()
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ class WelcomeSnapshotTests: XCTestCase {
|
|||
func testWelcomeSnapshot() throws {
|
||||
let store = Store(
|
||||
initialState: .placeholder,
|
||||
reducer: WelcomeReducer.default,
|
||||
environment: WelcomeEnvironment()
|
||||
reducer: WelcomeReducer()
|
||||
)
|
||||
|
||||
addAttachments(WelcomeView(store: store))
|
||||
|
|
Loading…
Reference in New Issue