Skip to content

Instantly share code, notes, and snippets.

@frontdevops
Created August 25, 2016 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frontdevops/cf35cac8305b57772c7c07f294bdb621 to your computer and use it in GitHub Desktop.
Save frontdevops/cf35cac8305b57772c7c07f294bdb621 to your computer and use it in GitHub Desktop.
class Instance {
constructor(public foo: number = 123) {}
}
let instance = new Instance;
export function getInstance() :Instance {
return instance;
}
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