Created
June 26, 2020 15:21
-
-
Save argodeep/55ffad4bf7a46b4ee6833791bebf7456 to your computer and use it in GitHub Desktop.
Redux Reducers
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
| import { ActionModel } from "../../models/action"; | |
| export function contacts (state = [], action: ActionModel) { | |
| switch (action.type) { | |
| case "GET_CONTACTS": | |
| return action.data | |
| default: | |
| return state; | |
| } | |
| } |
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
| import { combineReducers } from 'redux'; | |
| import { contacts } from './api'; | |
| import { isSorted } from './sort'; | |
| const allReducers = combineReducers({ | |
| contacts, isSorted | |
| }); | |
| export default allReducers; |
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
| import { ActionModel } from "../../models/action"; | |
| export function isSorted(state = false, action: ActionModel) { | |
| switch (action.type) { | |
| case "IS_SORTED": | |
| return action.data | |
| default: | |
| return state; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment