Last active
November 17, 2016 00:52
-
-
Save BerkeleyTrue/6b1b7b0e171874b7dacfd2a77e8e0ccf to your computer and use it in GitHub Desktop.
Convert thunk to observable
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 thunkToObservable(thunk) { | |
return (getState, ...args) => { | |
return new Observable(observer => { | |
const dispatchProxy = new Subject(); | |
const dispatch = action => dispatchProxy.next(action); | |
thunk(...args)(dispatch, getState); | |
return dispatchProxy.subscribe(observer); | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment