Skip to content

Commit 9c653ca

Browse files
authored
Merge pull request #10 from tmulry/master
added export to Singleton and removed src dir
2 parents d80a61e + e7339cc commit 9c653ca

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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" />

singleton/src/demo.ts renamed to singleton/demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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");

singleton/src/singleton.ts renamed to singleton/singleton.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
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",

0 commit comments

Comments
 (0)