Created
August 25, 2016 07:55
-
-
Save frontdevops/cf35cac8305b57772c7c07f294bdb621 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
class Instance { | |
constructor(public foo: number = 123) {} | |
} | |
let instance = new Instance; | |
export function getInstance() :Instance { | |
return instance; | |
} |
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
import * as Singleton from "singleton.ts"; | |
let obj1 = Singleton.getInstance(); | |
let obj2 = Singleton.getInstance(); | |
obj1.foo = 456; | |
console.log( obj1 === obj2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment