File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1- /// <reference path="singleton/src/ demo.ts" />
1+ /// <reference path="singleton/demo.ts" />
22/// <reference path="abstract_factory/demo.ts" />
33/// <reference path="factory_method/demo.ts" />
44/// <reference path="builder/demo.ts" />
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ namespace SingletonPattern {
33 export namespace Demo {
44
55 export function show ( ) : void {
6- var singleton1 = SingletonPattern . Singleton . Instance ;
7- var singleton2 = SingletonPattern . Singleton . Instance ;
6+ var singleton1 = SingletonPattern . Singleton . Instance ( ) ;
7+ var singleton2 = SingletonPattern . Singleton . Instance ( ) ;
88
99 if ( singleton1 === singleton2 ) {
1010 console . log ( "two singletons are equivalent" ) ;
Original file line number Diff line number Diff line change 1- namespace Singleton {
2- class Singleton {
1+ namespace SingletonPattern {
2+ export class Singleton {
33 // A variable which stores the singleton object. Intially,
44 // the variable acts like a placeholder
55 private static singleton : Singleton = null ;
66 // private constructor so that no instance is created
77 private constructor ( ) {
88 }
99 // This is how we create a singleton object
10- public static getInstance ( ) : Singleton {
10+ public static Instance ( ) : Singleton {
1111 // check if an instance of the class is already created
1212 if ( this . singleton == null ) {
1313 // If not created create an instance of the class
Original file line number Diff line number Diff line change 4444 " prototype/demo.ts" ,
4545 " proxy/proxy.ts" ,
4646 " proxy/demo.ts" ,
47- " singleton/src/ singleton.ts" ,
48- " singleton/src/ demo.ts" ,
47+ " singleton/singleton.ts" ,
48+ " singleton/demo.ts" ,
4949 " state/state.ts" ,
5050 " state/demo.ts" ,
5151 " strategy/strategy.ts" ,
You can’t perform that action at this time.
0 commit comments