Created
August 24, 2016 13:34
-
-
Save nesbtesh/9c8eb2480cbb6f766f9c511037bf2d75 to your computer and use it in GitHub Desktop.
Usage of createReducer.js
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
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