3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/redux/reducers.rb', line 3
def self.add_application_reducers_to_store
unless @_application_reducers_added
@_application_reducers_added = true
app_reducer = Redux.create_reducer do |prev_state, action|
case action[:type]
when 'APPLICATION_STATE'
if action.key?(:set_state)
action[:set_state]
else
new_state = {}.merge!(prev_state)
new_state.merge!(action[:name] => action[:value])
new_state
end
else
prev_state
end
end
Redux::Store.preloaded_state_merge!(application_state: {})
Redux::Store.add_reducers(application_state: app_reducer)
end
end
|