Skip to content

Instantly share code, notes, and snippets.

@fxck
Last active September 12, 2018 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fxck/e24b76a52334605c96d67ce9ee6fc4fb to your computer and use it in GitHub Desktop.
Save fxck/e24b76a52334605c96d67ce9ee6fc4fb to your computer and use it in GitHub Desktop.
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