Created
November 16, 2016 10:28
-
-
Save lmatteis/07585696df7ec041c46e9a58a4f1040b 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
// 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