Created
November 2, 2016 04:54
-
-
Save adnaan/226afb213ea7268e8dcebf4f5c8da0b9 to your computer and use it in GitHub Desktop.
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
reducers: { | |
query(state) { | |
return { ...state, loading: true, }; | |
}, | |
querySuccess(state, { payload }) { | |
return { ...state, loading: false, list: payload }; | |
}, | |
vote(state) { | |
return { ...state, loading: true }; | |
}, | |
voteSuccess(state, { payload }) { | |
const newList = state.list.map(product => { | |
if (product.id === payload) { | |
return { ...product, vote:product.vote + 1 }; | |
} else { | |
return product; | |
} | |
}); | |
return { ...state, list: newList, loading: false }; | |
}, | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment