Skip to content

Commit

Permalink
Merge pull request #42 from Ryu0118/deprecate-pullbackable
Browse files Browse the repository at this point in the history
Deprecate Pullbackable
  • Loading branch information
Ryu0118 authored Oct 4, 2023
2 parents b6a4099 + 08506ef commit 510934f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 77 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ struct ChildView: View, ActionSendable {
}

struct ChildReducer: ReducerProtocol {
enum Action: Pullbackable {
enum Action {
case onButtonTapped
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SimplexArchitecture/ActionSendable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public extension ActionSendable {
}
}

public extension ActionSendable where Reducer.Action: Pullbackable {
public extension ActionSendable {
/// Pullbacks the `Action` to the specified case path in the parent's reducer.
///
/// - Parameters:
Expand Down
56 changes: 0 additions & 56 deletions Sources/SimplexArchitecture/Reducer/Pullbackable.swift

This file was deleted.

21 changes: 4 additions & 17 deletions Sources/SimplexArchitecture/Store/Store+send.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,14 @@ extension Store {
defer {
switch action.kind {
case .viewAction(let action):
guard let pullbackAction else {
break
}
if let _ = Reducer.Action.self as? Pullbackable.Type {
pullbackAction(action)
} else {
runtimeWarning("\(Reducer.Action.self) must be conformed to Pullbackable in order to pullback to parent reducer")
}
guard let pullbackAction else { break }
pullbackAction(action)
case .reducerAction(let action):
guard let pullbackReducerAction else {
break
}
if let _ = Reducer.ReducerAction.self as? Pullbackable.Type {
pullbackReducerAction(action)
} else {
runtimeWarning("\(Reducer.ReducerAction.self) must be conformed to Pullbackable in order to pullback to parent reducer")
}
guard let pullbackReducerAction else { break }
pullbackReducerAction(action)
}
}


let sideEffect: SideEffect<Reducer>
// If Unit Testing is in progress and an action is sent from SideEffect
#if DEBUG
Expand Down
4 changes: 2 additions & 2 deletions Tests/SimplexArchitectureTests/StoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ private struct ParentReducer: ReducerProtocol {
}

private struct TestReducer: ReducerProtocol {
enum ReducerAction: Equatable, Pullbackable {
enum ReducerAction: Equatable {
case c3
case c4
}

enum Action: Equatable, Pullbackable {
enum Action: Equatable {
case c1
case c2
}
Expand Down

0 comments on commit 510934f

Please sign in to comment.