Skip to content

Instantly share code, notes, and snippets.

@nesbtesh
Created August 24, 2016 13:34
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 nesbtesh/9c8eb2480cbb6f766f9c511037bf2d75 to your computer and use it in GitHub Desktop.
Save nesbtesh/9c8eb2480cbb6f766f9c511037bf2d75 to your computer and use it in GitHub Desktop.
Usage of createReducer.js
import {createReducer} from '../../utils';
// Add the following for IE compatability
Object.assign = Object.assign || require('object-assign');
const initialState = {
'count': 0,
'receiving': false,
'pages': 0,
'documents': []
};
export default createReducer(initialState, {
['RECEIVED_DOCUMENTS']: (state, payload) => {
return {
'count': payload.count,
'pages': payload.pages,
'documents': payload.documents,
'receiving': false
};
},
['RETRIVING_DOCUMENTS']: (state, payload) => {
return Object.assign({}, state, {
'receiving': true
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment