Last active
September 12, 2018 08:43
-
-
Save fxck/e24b76a52334605c96d67ce9ee6fc4fb 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
class Users { | |
list[]: string; | |
loading: boolean; | |
constructor() { | |
this.list = []; | |
this.loading = false; | |
} | |
} | |
const initialState = new Users(); | |
function usersReducer(state = initialState, action: Action) { | |
switch (action.type) { | |
case 'USERS_LIST_REQUEST': | |
return { ...state, loading: true }; | |
case 'USERS_LIST_SUCCESS': | |
return { ...state, list: action.payload.list, loading: false }; | |
case 'USERS_LIST_FAILED': | |
return { ...state, loading: false }; | |
} | |
return state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment