lib/redux.rb in redux-0.1.0 vs lib/redux.rb in redux-0.1.1
- old
+ new
@@ -3,10 +3,16 @@
module Redux
def self.combine_reducers(reducers)
->(state = {}, action){
reducers.reduce({}){ |next_state, (key, reducer)|
- next_state[key] = reducer.call(state[key], action)
+ if state.key?(key)
+ next_state[key] = reducer.call(state[key], action)
+ else
+ next_state[key] = reducer.call(action)
+ end
+
+ next_state
}
}
end
end
\ No newline at end of file