Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.