Sha256: 8df9b23b44575c3bba1f91bbdf3c9ca41a57cb961bfb950800d41248c8cb597c

Contents?: true

Size: 820 Bytes

Versions: 32

Compression:

Stored size: 820 Bytes

Contents

module Isomorfeus
  module Data
    module Reducer
      def self.add_reducer_to_store
        data_reducer = Redux.create_reducer do |prev_state, action|
          action_type = action[:type]
          if action_type.JS.startsWith('DATA_')
            case action_type
            when 'DATA_STATE'
              if action.key?(:set_state)
                action[:set_state]
              else
                prev_state
              end
            when 'DATA_LOAD'
              prev_state.deep_merge(action[:data])
            else
              prev_state
            end
          else
            prev_state
          end
        end

        Redux::Store.preloaded_state_merge!(data_state: {})
        Redux::Store.add_reducer(data_state: data_reducer)
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
isomorfeus-data-2.0.21 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.20 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.19 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.18 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.17 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.16 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.15 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.14 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.13 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.12 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.11 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.10 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.9 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.8 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.7 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.6 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.5 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.4 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.3 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.2 lib/isomorfeus/data/reducer.rb