From 4986042428e24a04b73fb03d71c01353588419a7 Mon Sep 17 00:00:00 2001 From: Rainer Killinger Date: Mon, 25 Mar 2019 11:26:07 +0100 Subject: [PATCH] fix: change SCThingMeta getInstance() return value --- src/core/Thing.ts | 8 +++++--- src/core/things/Diff.ts | 5 ----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/core/Thing.ts b/src/core/Thing.ts index c90baa7f..f8dfc8f7 100644 --- a/src/core/Thing.ts +++ b/src/core/Thing.ts @@ -222,7 +222,7 @@ export class SCThingMeta implements SCMetaTranslations { /** * Set type definiton for singleton instance */ - protected static _instance: SCThingMeta; + protected static _instance = new Map(); /** * Translations of fields @@ -268,8 +268,10 @@ export class SCThingMeta implements SCMetaTranslations { * Function to retrieve typed singleton instance */ public static getInstance(): T { - const typedThis = this as any as typeof SCThingMeta; - return (typedThis._instance || (typedThis._instance = new this())) as T; + if (!this._instance.has(this.name)) { + this._instance.set(this.name, new this()); + } + return this._instance.get(this.name) as T; } protected constructor() {} diff --git a/src/core/things/Diff.ts b/src/core/things/Diff.ts index e2b9991f..44be0293 100644 --- a/src/core/things/Diff.ts +++ b/src/core/things/Diff.ts @@ -64,11 +64,6 @@ export interface SCDiff extends SCDiffWithoutReferences { * Meta information about a diff */ export class SCDiffMeta extends SCThingMeta implements SCMetaTranslations { - /** - * Set type definiton for singleton instance - */ - protected static _instance: SCThingMeta; - /** * Translations of fields */