templates/assets/js/store.rb in clearwater-roda-0.2.1 vs templates/assets/js/store.rb in clearwater-roda-0.2.2

- old
+ new

@@ -12,11 +12,11 @@ initial_state = AppState.new( counter: 0, ) -Store = GrandCentral::Store.new(initial_state) do |state, action| +handler = proc do |state, action| case action when Increment state.update counter: state.counter + 1 when Decrement state.update counter: state.counter - 1 @@ -27,9 +27,16 @@ # It is important to return a state object that matches the structure of # the previous one. It becomes the new app state. else state end +end + +# Allow swapping out handlers on the same store for hot-loaded code in dev. +if defined? Store + Store.handler = handler +else + Store = GrandCentral::Store.new(initial_state, &handler) end # When you want to use application state in a component, you can use this module # to add the attribute methods to that component using the following pattern: #