Skip to content

Instantly share code, notes, and snippets.

@ramzes13
Created March 14, 2019 12:33
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 ramzes13/ff150c812ca04810c73c406cb08794d9 to your computer and use it in GitHub Desktop.
Save ramzes13/ff150c812ca04810c73c406cb08794d9 to your computer and use it in GitHub Desktop.
reducer
const configs = (state: BookListsInterface = defaultState, action: any): BookListsInterface => {
switch (action.type) {
case bookListActions.BOOK_LIST_BEGIN_LOADING: {
const { loadingMeta } = state;
loadingMeta.isLoading += 1;
return { ...state, loadingMeta: Object.assign({}, loadingMeta) };
}
case bookListActions.BOOK_LIST_END_LOADING: {
const { loadingMeta } = state;
loadingMeta.isLoading -= 1;
loadingMeta.lastLoad = new Date();
return { ...state, loadingMeta: Object.assign({}, loadingMeta) };
}
case bookListActions.BOOK_LIST_SET_BOOK_LIST: {
// todo implement
return { ...state };
}
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment