Method: Rbdux::Store#dispatch

Defined in:
lib/rbdux/store.rb

#dispatch(action) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rbdux/store.rb', line 60

def dispatch(action)
  validate_store_container

  previous_state = @store_container.all

  dispatched_action = apply_before_middleware!(action)

  reducers.fetch(action.class.name, []).each do |reducer|
    apply_reducer!(reducer, dispatched_action)
  end

  apply_after_middleware!(previous_state, dispatched_action)

  observers.values.each(&:call)
end