- 所有的reducer会依次处理同样一个state
- 需要确保每个reducer处理逻辑没有问题
Reducer YourReducer01 = ^TheSameState * (id<Action> action, TheSameState *state) {
if (state == nil) {
// 需要处理nil 返回初始值
TheSameState *nextState = [TheSameState new];
return nextState;
}
if ([state isKindOfClass:[TheSameState class]]) {
// do something
}
return state;
};
Reducer YourReducer02 = ^TheSameState * (id<Action> action, TheSameState *state) {
if (state == nil) {
// 需要处理nil 返回初始值
TheSameState *nextState = [TheSameState new];
return nextState;
}
if ([state isKindOfClass:[TheSameState class]]) {
// do something
}
return state;
};
#import <Redux/Reduce.h>
Reducer reducer = reduceReducers(@[YourReducer01, YourReducer02,...]);
Store *store = [[Store alloc] initWithReducer:reducer
state:nil
middlewares:@[middleware01, middleware02, ...]];
详细内容参见Demo
中的ReduceReducers Demo