Skip to content

Instantly share code, notes, and snippets.

@zarkomilosevic
Created August 31, 2017 20:23
Show Gist options
  • Save zarkomilosevic/d0040934a5dfb0cca8722390d5f7e24a to your computer and use it in GitHub Desktop.
Save zarkomilosevic/d0040934a5dfb0cca8722390d5f7e24a to your computer and use it in GitHub Desktop.
'user strict'
import {ReduceStore} from 'flux/utils';
import TodoDispatcher from './TodoDispatcher';
import TodoActionTypes from './TodoActionTypes';
class TodoErrorsStore extends ReduceStore {
constructor(){
super(TodoDispatcher);
}
getInitialState(){
return {
add: {},
edit: {},
}
}
reduce(state, action){
switch (action.type){
case TodoActionTypes.ADD_TODO_ERROR:
return ({
add: action.errors,
edit: {},
});
case TodoActionTypes.EDIT_TODO_ERROR:
debugger;
return ({
add: {},
edit: action.errors,
});
case TodoActionTypes.EDIT_TODO:
case TodoActionTypes.UPDATE_DRAFT:
return this.getInitialState();
default:
return state;
}
}
}
export default new TodoErrorsStore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment