Skip to content

Instantly share code, notes, and snippets.

@mvbattan
Created November 28, 2018 21:25
Show Gist options
  • Save mvbattan/d85dfb912578a087dd3e9f19a0bdc2eb to your computer and use it in GitHub Desktop.
Save mvbattan/d85dfb912578a087dd3e9f19a0bdc2eb to your computer and use it in GitHub Desktop.
dService
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