Created
November 28, 2018 21:25
-
-
Save mvbattan/d85dfb912578a087dd3e9f19a0bdc2eb to your computer and use it in GitHub Desktop.
dService
This file contains 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 { wrapService, withPostSuccess } from 'redux-recompose'; | |
import responseBody from './response'; | |
// Declare your api calls | |
const getCards = async () => new Promise(resolve => setTimeout(() => resolve(responseBody), 1000)); | |
// Declare your customizations, used by fetchMiddleware | |
getCards.successSelector = response => response.cards; | |
getCards.injections = [ | |
withPostSuccess((dispatch, response, state) => alert(`Fetched at: ${state.hearthstone.count}`)) | |
]; | |
const service = { | |
getCards | |
}; | |
// Export your service by also specifying the reducer name and the target for each action. | |
export default wrapService(service, 'hearthstone', { getCards: 'cards' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment