Sha256: 78ea2ee635c07ff426d4dfe5689351b9c427ee726423fcf064f1d4e180777e44
Contents?: true
Size: 1.73 KB
Versions: 3
Compression:
Stored size: 1.73 KB
Contents
module React module ReduxComponent module Reducers def self.add_component_reducers_to_store component_reducer = Redux.create_reducer do |prev_state, action| case action[:type] when 'COMPONENT_STATE' new_state = {}.merge!(prev_state) # make a copy of state new_state[action[:object_id]] = {} unless new_state.has_key?(action[:object_id]) new_state[action[:object_id]].merge!(action[:name] => action[:value]) new_state when 'INIT' new_state = {} new_state else prev_state end end component_class_reducer = Redux.create_reducer do |prev_state, action| case action[:type] when 'COMPONENT_CLASS_STATE' new_state = {}.merge!(prev_state) # make a copy of state new_state[action[:class]] = {} unless new_state.has_key?(action[:class]) new_state[action[:class]].merge!(action[:name] => action[:value]) new_state when 'INIT' new_state = {} new_state else prev_state end end app_reducer = Redux.create_reducer do |prev_state, action| case action[:type] when 'APPLICATION_STATE' new_state = {}.merge!(prev_state) # make a copy of state new_state.merge!(action[:name] => action[:value]) new_state when 'INIT' new_state = {} new_state else prev_state end end Redux::Store.add_reducers(component_state: component_reducer, component_class_state: component_class_reducer, application_state: app_reducer) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
isomorfeus-react-16.6.2 | lib/react/redux_component/reducers.rb |
isomorfeus-react-16.6.1 | lib/react/redux_component/reducers.rb |
isomorfeus-react-16.5.1 | lib/react/redux_component/reducers.rb |