@memberjunction/global
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -7,6 +7,7 @@ /** | ||
export declare abstract class BaseSingleton<T> { | ||
private static _globalKeyPrefix; | ||
private _globalKey; | ||
get GlobalKey(): string; | ||
protected constructor(globalKey: string); | ||
protected static getInstance<T extends BaseSingleton<any>>(this: new () => T, globalKey: string): T; | ||
protected constructor(); | ||
protected static getInstance<T extends BaseSingleton<any>>(this: new () => T): T; | ||
/** | ||
@@ -13,0 +14,0 @@ * The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared |
@@ -14,4 +14,4 @@ "use strict"; | ||
} | ||
constructor(globalKey) { | ||
this._globalKey = globalKey; | ||
constructor() { | ||
this._globalKey = BaseSingleton._globalKeyPrefix + this.constructor.name; | ||
const g = (0, _1.GetGlobalObjectStore)(); | ||
@@ -26,8 +26,9 @@ if (g && g[this.GlobalKey]) { | ||
} | ||
static getInstance(globalKey) { | ||
static getInstance() { | ||
const key = BaseSingleton._globalKeyPrefix + this.name; // use the class name as the key | ||
const g = (0, _1.GetGlobalObjectStore)(); | ||
if (!g[globalKey]) { | ||
g[globalKey] = new this(); | ||
if (!g[key]) { | ||
g[key] = new this(); | ||
} | ||
return g[globalKey]; | ||
return g[key]; | ||
} | ||
@@ -44,2 +45,3 @@ /** | ||
exports.BaseSingleton = BaseSingleton; | ||
BaseSingleton._globalKeyPrefix = '___'; | ||
//# sourceMappingURL=BaseSingleton.js.map |
@@ -20,6 +20,4 @@ import * as MJ from './interface'; | ||
private _components; | ||
private static _instance; | ||
private _classFactory; | ||
private _properties; | ||
private constructor(); | ||
/** | ||
@@ -26,0 +24,0 @@ * Returns the global instance of the MJGlobal class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of MJGlobal, always use this method to get the instance. |
@@ -34,3 +34,3 @@ "use strict"; | ||
constructor() { | ||
super('MJGlobalInstance'); | ||
super(...arguments); | ||
// subjects for observables to handle eventing | ||
@@ -51,3 +51,3 @@ this._eventsSubject = new rxjs_1.Subject(); | ||
static get Instance() { | ||
return super.getInstance('MJGlobalInstance'); | ||
return super.getInstance(); | ||
} | ||
@@ -54,0 +54,0 @@ RegisterComponent(component) { |
{ | ||
"name": "@memberjunction/global", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "MemberJunction: Global Object - Needed for ALL other MJ components", | ||
@@ -19,3 +19,3 @@ "main": "dist/index.js", | ||
"ts-node-dev": "^2.0.0", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.4.5" | ||
}, | ||
@@ -22,0 +22,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59510
758