Created
January 8, 2019 21:01
-
-
Save beaucollins/62a2d5c5733f8a0dd448b8d4aca2131b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 asyncReaction<T: ActionTypes>(detector: Detector<T>, handler: Handler<T>): AppMiddleware { | |
| return store => next => action => { | |
| const detected = detector(action); | |
| if (detected !== null) { | |
| handler(detected, store.getState()).then(store.dispatch); | |
| } | |
| return next(action); | |
| } | |
| } | |
| const middleware = asyncReaction(isProjectsCreate, createProjectHTTP); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment