Skip to content

Instantly share code, notes, and snippets.

@rrdelaney
Created July 7, 2017 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrdelaney/f8b19c4c1142e2c4214602087747dc8d to your computer and use it in GitHub Desktop.
Save rrdelaney/f8b19c4c1142e2c4214602087747dc8d to your computer and use it in GitHub Desktop.
Redux Async Iterator
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