Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Created November 16, 2016 10:28
Show Gist options
  • Save lmatteis/07585696df7ec041c46e9a58a4f1040b to your computer and use it in GitHub Desktop.
Save lmatteis/07585696df7ec041c46e9a58a4f1040b to your computer and use it in GitHub Desktop.
// Runs resetError() AFTER storeToken(token)
export function renewToken({ clientId, redirectUri }) {
return (dispatch, getState) => {
getOAuthToken({ clientId, redirectUri })
.then(token =>
dispatch(storeToken(token))
)
.then(() => {
dispatch(resetError());
});
};
}
// How to achieve this using redux-observable,
// considering that storeToken(token) is a thunk and resetError() a plain object?
function handleRenew(action$) {
return action$.ofType(RENEW_TOKEN)
.mergeMap(action => getOAuthToken(action.payload))
.map(token => storeToken(token))
// here I need to "resolve" the storeToken(token) thunk
// and emit resetError(), but I don't understand how
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment