Last active
April 16, 2018 17:32
-
-
Save wesleyduff/1eb7df30b5af054420cf4ee86e6500f9 to your computer and use it in GitHub Desktop.
JavaScript Singleton Pattern
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
let logger_instance = null; | |
class Logger { | |
constructor() { | |
} | |
static instance(message, user, serviceError, note, code){ | |
console.log('static instance called'); | |
if(logger_instance === null){ | |
console.log('==== create'); | |
logger_instance = new Logger(); | |
} | |
console.log('instance', logger_instance); | |
console.log('type', typeof logger_instance); | |
return logger_instance | |
} | |
} | |
var log = Logger.instance(); | |
var _log = Logger.instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment