Sha256: cda21261b50cda534bfa39553f2c0b86eef6a5efe63c2e4ada4efc50199191c0

Contents?: true

Size: 405 Bytes

Versions: 2

Compression:

Stored size: 405 Bytes

Contents

require_relative "redux/version"
require_relative "redux/store"

module Redux
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redux-0.1.2 lib/redux.rb
redux-0.1.1 lib/redux.rb