Skip to content

Commit c629219

Browse files
author
Charlotte Tortorella
committed
Add a new concatReducers variant
1 parent 2552814 commit c629219

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

ReactiveReSwift.xcodeproj/project.pbxproj

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -457,20 +457,23 @@
457457
TargetAttributes = {
458458
25DBCF361C30BF2B00D63A58 = {
459459
CreatedOnToolsVersion = 7.2;
460+
LastSwiftMigration = 1020;
460461
};
461462
25DBCF4D1C30C18D00D63A58 = {
462463
CreatedOnToolsVersion = 7.2;
464+
LastSwiftMigration = 1020;
463465
};
464466
25DBCF631C30C1AC00D63A58 = {
465467
CreatedOnToolsVersion = 7.2;
468+
LastSwiftMigration = 1020;
466469
};
467470
25DBCF7A1C30C4AA00D63A58 = {
468471
CreatedOnToolsVersion = 7.2;
469-
LastSwiftMigration = 0900;
472+
LastSwiftMigration = 1020;
470473
};
471474
25DBCF861C30C4DB00D63A58 = {
472475
CreatedOnToolsVersion = 7.2;
473-
LastSwiftMigration = 0900;
476+
LastSwiftMigration = 1020;
474477
};
475478
625E66821C1FF97E0027C288 = {
476479
CreatedOnToolsVersion = 7.1.1;
@@ -744,6 +747,7 @@
744747
PRODUCT_NAME = ReactiveReSwift;
745748
SDKROOT = watchos;
746749
SKIP_INSTALL = YES;
750+
SWIFT_VERSION = 5.0;
747751
TARGETED_DEVICE_FAMILY = 4;
748752
};
749753
name = Debug;
@@ -765,6 +769,7 @@
765769
SDKROOT = watchos;
766770
SKIP_INSTALL = YES;
767771
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
772+
SWIFT_VERSION = 5.0;
768773
TARGETED_DEVICE_FAMILY = 4;
769774
};
770775
name = Release;
@@ -784,6 +789,7 @@
784789
PRODUCT_NAME = ReactiveReSwift;
785790
SDKROOT = appletvos;
786791
SKIP_INSTALL = YES;
792+
SWIFT_VERSION = 5.0;
787793
TARGETED_DEVICE_FAMILY = 3;
788794
};
789795
name = Debug;
@@ -804,6 +810,7 @@
804810
SDKROOT = appletvos;
805811
SKIP_INSTALL = YES;
806812
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
813+
SWIFT_VERSION = 5.0;
807814
TARGETED_DEVICE_FAMILY = 3;
808815
};
809816
name = Release;
@@ -816,6 +823,8 @@
816823
PRODUCT_BUNDLE_IDENTIFIER = "reswift.github.io.ReSwift-tvOSTests";
817824
PRODUCT_NAME = "$(TARGET_NAME)";
818825
SDKROOT = appletvos;
826+
SWIFT_VERSION = 5.0;
827+
TARGETED_DEVICE_FAMILY = 3;
819828
};
820829
name = Debug;
821830
};
@@ -828,6 +837,8 @@
828837
PRODUCT_NAME = "$(TARGET_NAME)";
829838
SDKROOT = appletvos;
830839
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
840+
SWIFT_VERSION = 5.0;
841+
TARGETED_DEVICE_FAMILY = 3;
831842
};
832843
name = Release;
833844
};
@@ -848,8 +859,7 @@
848859
PRODUCT_NAME = ReactiveReSwift;
849860
SDKROOT = macosx;
850861
SKIP_INSTALL = YES;
851-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
852-
SWIFT_VERSION = 4.0;
862+
SWIFT_VERSION = 5.0;
853863
};
854864
name = Debug;
855865
};
@@ -870,8 +880,7 @@
870880
PRODUCT_NAME = ReactiveReSwift;
871881
SDKROOT = macosx;
872882
SKIP_INSTALL = YES;
873-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
874-
SWIFT_VERSION = 4.0;
883+
SWIFT_VERSION = 5.0;
875884
};
876885
name = Release;
877886
};
@@ -886,8 +895,7 @@
886895
PRODUCT_BUNDLE_IDENTIFIER = "reswift.github.io.ReSwift-MacTests";
887896
PRODUCT_NAME = "$(TARGET_NAME)";
888897
SDKROOT = macosx;
889-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
890-
SWIFT_VERSION = 4.0;
898+
SWIFT_VERSION = 5.0;
891899
};
892900
name = Debug;
893901
};
@@ -902,8 +910,7 @@
902910
PRODUCT_BUNDLE_IDENTIFIER = "reswift.github.io.ReSwift-MacTests";
903911
PRODUCT_NAME = "$(TARGET_NAME)";
904912
SDKROOT = macosx;
905-
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
906-
SWIFT_VERSION = 4.0;
913+
SWIFT_VERSION = 5.0;
907914
};
908915
name = Release;
909916
};

Sources/CoreTypes/Reducer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import Foundation
1111
public typealias Reducer<State> = (_ action: Action, _ state: State) -> State
1212

1313
public func concatReducers<State>(_ first: @escaping Reducer<State>, _ rest: Reducer<State>...) -> Reducer<State> {
14+
return concatReducers(first: first, rest: rest)
15+
}
16+
17+
public func concatReducers<State>(first: @escaping Reducer<State>, rest: [Reducer<State>]) -> Reducer<State> {
1418
return { action, state in
1519
rest.reduce(first(action, state)) { state, reducer in
1620
reducer(action, state)

Tests/ReducerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ReducerTests: XCTestCase {
5252
it combines the results from each individual reducer correctly
5353
*/
5454
func testCombinesReducerResults() {
55-
let combinedReducer = concatReducers(increaseByOneReducer, increaseByTwoReducer)
55+
let combinedReducer = concatReducers(first: increaseByOneReducer, rest: [increaseByTwoReducer])
5656
let newState = combinedReducer(NoOpAction(), CounterState())
5757

5858
XCTAssertEqual(newState.count, 3)

0 commit comments

Comments
 (0)