Created
July 7, 2017 06:02
-
-
Save rrdelaney/f8b19c4c1142e2c4214602087747dc8d to your computer and use it in GitHub Desktop.
Redux Async Iterator
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
const asyncGeneratorMiddleware = async ({ dispatch }) => next => action => { | |
if (typeof action === 'function') { | |
for await (const _action of action()) { | |
dispatch(x) | |
} | |
} else { | |
return next(action) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment