@memberjunction/global 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,16 @@ export declare abstract class BaseSingleton<T> {
8
8
  private _globalKey;
9
9
  get GlobalKey(): string;
10
10
  protected constructor();
11
- protected static getInstance<T extends BaseSingleton<any>>(this: new () => T): T;
11
+ /**
12
+ * Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store.
13
+ * If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used.
14
+ * NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest
15
+ * level class name will be used.
16
+ * @param this
17
+ * @param className
18
+ * @returns
19
+ */
20
+ protected static getInstance<T extends BaseSingleton<any>>(this: new () => T, className?: string): T;
12
21
  /**
13
22
  * 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
23
  * because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.
@@ -1 +1 @@
1
- {"version":3,"file":"BaseSingleton.d.ts","sourceRoot":"","sources":["../src/BaseSingleton.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,8BAAsB,aAAa,CAAC,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAiB;IAChD,OAAO,CAAC,UAAU,CAAS;IAC3B,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,SAAS;IAcT,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC;IAShF;;;;OAIG;IACI,oBAAoB;CAG9B"}
1
+ {"version":3,"file":"BaseSingleton.d.ts","sourceRoot":"","sources":["../src/BaseSingleton.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,8BAAsB,aAAa,CAAC,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAiB;IAChD,OAAO,CAAC,UAAU,CAAS;IAC3B,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,SAAS;IAcT;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC;IASpG;;;;OAIG;IACI,oBAAoB;CAG9B"}
@@ -22,8 +22,17 @@ class BaseSingleton {
22
22
  g[this.GlobalKey] = this;
23
23
  }
24
24
  }
25
- static getInstance() {
26
- const key = BaseSingleton._globalKeyPrefix + this.name; // use the class name as the key
25
+ /**
26
+ * Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store.
27
+ * If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used.
28
+ * NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest
29
+ * level class name will be used.
30
+ * @param this
31
+ * @param className
32
+ * @returns
33
+ */
34
+ static getInstance(className) {
35
+ const key = BaseSingleton._globalKeyPrefix + (className || this.name); // use the class name as the key
27
36
  const g = (0, _1.GetGlobalObjectStore)();
28
37
  if (!g[key]) {
29
38
  g[key] = new this();
@@ -1 +1 @@
1
- {"version":3,"file":"BaseSingleton.js","sourceRoot":"","sources":["../src/BaseSingleton.ts"],"names":[],"mappings":";;;AAAA,wBAAyC;AAEzC;;;;GAIG;AACH,MAAsB,aAAa;IAG/B,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD;QACI,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QACzE,MAAM,CAAC,GAAG,IAAA,uBAAoB,GAAE,CAAC;QAEjC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QAC1D,IAAI,CAAC,EAAE,CAAC;YACJ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAC7B,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACO,MAAM,CAAC,WAAW,CAAkD,SAAkB;QAC5F,MAAM,GAAG,GAAG,aAAa,CAAC,gBAAgB,GAAG,CAAC,SAAS,IAAK,IAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,gCAAgC;QACrH,MAAM,CAAC,GAAG,IAAA,uBAAoB,GAAE,CAAC;QACjC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,CAAC;QACD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,oBAAoB;QACvB,OAAO,IAAA,uBAAoB,GAAE,CAAC;IAClC,CAAC;;AA7CL,sCA8CC;AA7CkB,8BAAgB,GAAW,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/global",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "MemberJunction: Global Object - Needed for ALL other MJ components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",