Skip to content

Instantly share code, notes, and snippets.

@ramzes13
Created March 14, 2019 12:33
Embed
What would you like to do?
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