Created
August 31, 2017 20:23
-
-
Save zarkomilosevic/d0040934a5dfb0cca8722390d5f7e24a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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