Created
February 3, 2019 11:05
-
-
Save binary10ve/48da7f2a39333d0340c166f48950be96 to your computer and use it in GitHub Desktop.
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 getAppEnv = (function(){ | |
class AppEnv{ | |
constructor(platform, buildVersion){ | |
this.platform = platform; | |
this.buildVersion = buildVersion; | |
this.cacheEnabled = false; | |
} | |
enableCache(){ | |
this.cacheEnabled = true; | |
} | |
} | |
let appEnv = null; | |
return function(){ | |
if(appEnv == null){ | |
console.log("Fetching for the first Time"); | |
appEnv = new AppEnv("unix","10.1.1"); | |
}else{ | |
console.log("Fetching second Time"); | |
} | |
return appEnv; | |
} | |
}()); | |
p = getAppEnv(); | |
console.log(p.cacheEnabled); | |
c = getAppEnv(); | |
console.log(c.cacheEnabled); | |
p.enableCache() | |
console.log(p.cacheEnabled); | |
console.log(c.cacheEnabled); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment