Skip to content

Instantly share code, notes, and snippets.

@AlexKott
Last active September 10, 2018 07:24
Show Gist options
  • Save AlexKott/8bd7234c975518652a274404cf69164d to your computer and use it in GitHub Desktop.
Save AlexKott/8bd7234c975518652a274404cf69164d to your computer and use it in GitHub Desktop.
You can use this in combination with a request middleware (https://gist.github.com/AlexKott/d0b36882e873ec931d69f5d9cc2c7e7f)
import * as actions from '@/actions';
import * as t from '@/actions/types';
export default store => next => action => {
if (action.type === t.SEND_REQUEST) {
store.dispatch(actions.incrementLoading());
if (!action.payload.onFinally) {
action.payload.onFinally = [];
}
action.payload.onFinally.push(dispatch => dispatch(actions.decrementLoading()));
}
return next(action);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment