Skip to content

Instantly share code, notes, and snippets.

@BerkeleyTrue
Last active November 17, 2016 00:52
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 BerkeleyTrue/6b1b7b0e171874b7dacfd2a77e8e0ccf to your computer and use it in GitHub Desktop.
Save BerkeleyTrue/6b1b7b0e171874b7dacfd2a77e8e0ccf to your computer and use it in GitHub Desktop.
Convert thunk to observable
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