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.1 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc10 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc9 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc8 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc7 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc6 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc5 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc4 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc3 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc2 lib/isomorfeus/data/reducer.rb
isomorfeus-data-2.0.0.rc1 lib/isomorfeus/data/reducer.rb