Created
May 19, 2019 23:31
-
-
Save nadeesha/a98d66457598bd1c6f518732e6a0c546 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 storeLanguageCode = tryCatch({ | |
tryer: (languageCode) => { | |
window.localStorage.setItem("LANG_CODE", languageCode); | |
return true; | |
}, | |
catcher: (languageCode, errorMessage) => { | |
logger.log(`${errorMessage} <-- happened while storing ${languageCode}`); | |
return false; | |
} | |
}); | |
const setUserLanguageCode = pipe( | |
getLanguageCode, | |
languageCode => storeLanguageCode(langaugeCode), // or just storeLanguageCode | |
storedSuccessfully => ({ storedSuccessfully }) | |
); | |
// setUserLanguageCode("en-US") will work as before. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment