Skip to content

Instantly share code, notes, and snippets.

@josephbridgwaterrowe
Created July 12, 2016 18:30
Show Gist options
  • Save josephbridgwaterrowe/fddbc40d4dfe1336fb5927a4e254e8a4 to your computer and use it in GitHub Desktop.
Save josephbridgwaterrowe/fddbc40d4dfe1336fb5927a4e254e8a4 to your computer and use it in GitHub Desktop.
thenMiddleware
function thenMiddleware() {
return next => action => {
const { then, type, ...rest } = action;
if (!then) {
return next(action);
}
next({ ...rest, type });
if (typeof then === 'string') {
return next({ ...rest, type: then });
} else {
then.forEach(type => {
next({ ...rest, type });
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment