Created
July 12, 2016 18:30
-
-
Save josephbridgwaterrowe/fddbc40d4dfe1336fb5927a4e254e8a4 to your computer and use it in GitHub Desktop.
thenMiddleware
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
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