Created
July 31, 2020 15:29
-
-
Save boostup/60bed5c9abf03d187c51faa1a64ddec7 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
const responseGoogleStatus = (responseType) => { | |
return (response) => { | |
console.log(responseType, response); | |
if (responseType == "Success") { | |
loggedIn = true; | |
token = response.accessToken; | |
} | |
if (responseType == "Failed") { | |
throw new Exception("Some error from Google API response", response); | |
} | |
}; | |
}; | |
//Then call the currying function to get a function back with 'responsType' (in this case) already 'filled in' | |
const successFn = responseGoogleStatus("Success") | |
const failureFn = responseGoogleStatus("Failed") | |
//Finally use successFn and failureFn as a callbacks for an API Promise for example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment