Last active
May 26, 2022 08:36
-
-
Save shcyiza/f982bc6adeeefaf905bffd9692343b1f to your computer and use it in GitHub Desktop.
showing off how to dynamically invoke function in JS
This file contains 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 OAUTH2_OPTIONS = { | |
facebookLogin() { | |
// do the oath2 procedure for FB | |
}, | |
googleLogin() { | |
// do the oath2 procedure for google | |
}, | |
instagramLogin() { | |
// do the oath2 procedure for instagram | |
} | |
} | |
function dispatchSocial(social) { | |
const valid_socials = ["facebook", "google", "instagram"] | |
if (valid_socials.includes(social)) { // validate social argument before execution | |
OUATH2_OPTIONS[social + "Login"]() // calling the logins method dynamically here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment