Last active
April 5, 2019 12:45
-
-
Save JeromeFranco/d100124fa421fb8ca7093804fc88d2f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// todo-actions.js | |
import { createAction } from 'redux-starter-kit'; | |
// Create an action creator | |
export const addTodo = createAction('TODO/ADD_TODO'); | |
// todo-reducers.js | |
import { addTodo } from './todo-actions'; | |
export function todosReducer(state = [], action) { | |
switch(action.type) { | |
// Use the action creator's type property to handle action | |
case addTodo.type: | |
return state.concat(action.payload); | |
default: | |
return state; | |
} | |
} | |
// todo-sagas.js | |
import { addTodo } from './todo-actions'; | |
function* addTodoSaga({ payload }) { | |
// Some side effects | |
} | |
// Use the action creator's type property to handle action | |
export default takeLatest(addTodo.type, addTodoSaga); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment