Module: Redux

Defined in:
lib/redux.rb,
lib/redux/store.rb,
lib/redux/version.rb

Defined Under Namespace

Classes: Store

Constant Summary collapse

VERSION =
"0.1.1".freeze

Class Method Summary collapse

Class Method Details

.combine_reducers(reducers) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/redux.rb', line 5

def self.combine_reducers(reducers)
  ->(state = {}, action){
    reducers.reduce({}){ |next_state, (key, reducer)|
      if state.key?(key)
        next_state[key] = reducer.call(state[key], action)
      else
        next_state[key] = reducer.call(action)
      end

      next_state
    }
  }
end