@memberjunction/global 1.4.0 → 1.5.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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Generic, abstract base class for any scenario where we want to use a Singleton pattern. This base class abstracts away the complexity of ensuring a truly global
3
+ * singleton instance across multiple code paths in a deployed application. It uses a Global Object Store to ensure that only one instance of the class exists in the application even
4
+ * if the class has code imported into multiple execution paths (which is not optimal, of course, but can occur in some situations).
5
+ */
6
+ export declare abstract class BaseSingleton<T> {
7
+ private _globalKey;
8
+ get GlobalKey(): string;
9
+ protected constructor(globalKey: string);
10
+ protected static getInstance<T extends BaseSingleton<any>>(this: new () => T, globalKey: string): T;
11
+ /**
12
+ * 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
13
+ * 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.
14
+ * @returns
15
+ */
16
+ GetGlobalObjectStore(): typeof globalThis;
17
+ }
18
+ //# sourceMappingURL=BaseSingleton.d.ts.map
@@ -0,0 +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,UAAU,CAAS;IAC3B,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,SAAS,aAAa,SAAS,EAAE,MAAM;IAcvC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;IAQnG;;;;OAIG;IACI,oBAAoB;CAG9B"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSingleton = void 0;
4
+ const _1 = require(".");
5
+ /**
6
+ * Generic, abstract base class for any scenario where we want to use a Singleton pattern. This base class abstracts away the complexity of ensuring a truly global
7
+ * singleton instance across multiple code paths in a deployed application. It uses a Global Object Store to ensure that only one instance of the class exists in the application even
8
+ * if the class has code imported into multiple execution paths (which is not optimal, of course, but can occur in some situations).
9
+ */
10
+ class BaseSingleton {
11
+ get GlobalKey() {
12
+ return this._globalKey;
13
+ }
14
+ constructor(globalKey) {
15
+ this._globalKey = globalKey;
16
+ const g = (0, _1.GetGlobalObjectStore)();
17
+ if (g && g[this.GlobalKey]) {
18
+ return g[this.GlobalKey];
19
+ }
20
+ // If we get here, we are the first instance of this class
21
+ if (g) {
22
+ g[this.GlobalKey] = this;
23
+ }
24
+ }
25
+ static getInstance(globalKey) {
26
+ const g = (0, _1.GetGlobalObjectStore)();
27
+ if (!g[globalKey]) {
28
+ g[globalKey] = new this();
29
+ }
30
+ return g[globalKey];
31
+ }
32
+ /**
33
+ * 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
34
+ * 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.
35
+ * @returns
36
+ */
37
+ GetGlobalObjectStore() {
38
+ return (0, _1.GetGlobalObjectStore)();
39
+ }
40
+ }
41
+ exports.BaseSingleton = BaseSingleton;
42
+ //# sourceMappingURL=BaseSingleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseSingleton.js","sourceRoot":"","sources":["../src/BaseSingleton.ts"],"names":[],"mappings":";;;AAAA,wBAAyC;AAEzC;;;;GAIG;AACH,MAAsB,aAAa;IAE/B,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD,YAAsB,SAAiB;QACnC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,MAAM,CAAC,GAAG,IAAA,uBAAoB,GAAE,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QAED,0DAA0D;QAC1D,IAAI,CAAC,EAAE,CAAC;YACJ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAC7B,CAAC;IACL,CAAC;IAES,MAAM,CAAC,WAAW,CAAkD,SAAiB;QAC3F,MAAM,CAAC,GAAG,IAAA,uBAAoB,GAAE,CAAC;QACjC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;YAChB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,CAAC;QACD,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,oBAAoB;QACvB,OAAO,IAAA,uBAAoB,GAAE,CAAC;IAClC,CAAC;CACJ;AAnCD,sCAmCC"}
@@ -22,7 +22,7 @@ export declare class ClassFactory {
22
22
  * @param baseClass A reference to the base class you are registering a sub-class for
23
23
  * @param subClass A reference to the sub-class you are registering
24
24
  * @param key A key can be used to differentiate registrations for the same base class/sub-class combination. For example, in the case of BaseEntity and Entity object subclasses we'll have a LOT of entries and we want to get the highest priority registered sub-class for a specific key. In that case, the key is the entity name, but the key can be any value you want to use to differentiate registrations.
25
- * @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used.
25
+ * @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used. Finally, if you do NOT provide this setting, the order of registrations will increment the priority automatically so dependency injection will typically care care of this. That is, in order for Class B, a subclass of Class A, to be registered properly, Class A code has to already have been loaded and therefore Class A's RegisterClass decorator was run. In that scenario, if neither Class A or B has a priority setting, Class A would be 1 and Class B would be 2 automatically. For this reason, you only need to explicitly set priority if you want to do something atypical as this mechanism normally will solve for setting the priority correctly based on the furthest descendant class that is registered.
26
26
  */
27
27
  Register(baseClass: any, subClass: any, key?: string, priority?: number): void;
28
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ClassFactory.d.ts","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],"mappings":"AAAA;;;;;;wGAMwG;AAGxG,qBAAa,iBAAiB;IAC1B,SAAS,EAAE,GAAG,CAAA;IACd,QAAQ,EAAE,GAAG,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IAEX,QAAQ,EAAE,MAAM,CAAA;CACnB;AAGD;;;GAGG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,cAAc,CAA2B;IAEjD;;;;;;OAMG;IACI,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAE,MAAa,EAAE,QAAQ,GAAE,MAAU;IAoBvF;;OAEG;IACI,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAa,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;IAqBxF;;;;;OAKG;IACI,mBAAmB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAkB,GAAG,iBAAiB,EAAE;IAWxF;;OAEG;IACI,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAkB,GAAG,iBAAiB;CAmBrF"}
1
+ {"version":3,"file":"ClassFactory.d.ts","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],"mappings":"AAAA;;;;;;wGAMwG;AAGxG,qBAAa,iBAAiB;IAC1B,SAAS,EAAE,GAAG,CAAA;IACd,QAAQ,EAAE,GAAG,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IAEX,QAAQ,EAAE,MAAM,CAAA;CACnB;AAGD;;;GAGG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,cAAc,CAA2B;IAEjD;;;;;;OAMG;IACI,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAE,MAAa,EAAE,QAAQ,GAAE,MAAU;IAmCvF;;OAEG;IACI,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAa,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;IAqBxF;;;;;OAKG;IACI,mBAAmB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAkB,GAAG,iBAAiB,EAAE;IAWxF;;OAEG;IACI,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAkB,GAAG,iBAAiB;CAmBrF"}
@@ -24,16 +24,29 @@ class ClassFactory {
24
24
  * @param baseClass A reference to the base class you are registering a sub-class for
25
25
  * @param subClass A reference to the sub-class you are registering
26
26
  * @param key A key can be used to differentiate registrations for the same base class/sub-class combination. For example, in the case of BaseEntity and Entity object subclasses we'll have a LOT of entries and we want to get the highest priority registered sub-class for a specific key. In that case, the key is the entity name, but the key can be any value you want to use to differentiate registrations.
27
- * @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used.
27
+ * @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used. Finally, if you do NOT provide this setting, the order of registrations will increment the priority automatically so dependency injection will typically care care of this. That is, in order for Class B, a subclass of Class A, to be registered properly, Class A code has to already have been loaded and therefore Class A's RegisterClass decorator was run. In that scenario, if neither Class A or B has a priority setting, Class A would be 1 and Class B would be 2 automatically. For this reason, you only need to explicitly set priority if you want to do something atypical as this mechanism normally will solve for setting the priority correctly based on the furthest descendant class that is registered.
28
28
  */
29
29
  Register(baseClass, subClass, key = null, priority = 0) {
30
30
  if (baseClass && subClass) {
31
31
  // get all of hte existing registrations for this baseClass and key
32
32
  const registrations = this.GetAllRegistrations(baseClass, key);
33
- // validate to make sure that the comabintion of base class and key for the provided priority # is not already registered, if it is, then throw an exception
34
- const existing = registrations.filter(r => r.Priority === priority);
35
- if (existing && existing.length > 0) {
36
- console.warn(`*** ClassFactory.Register: Registering class ${subClass.name} for base class ${baseClass.name} and key/priority ${key}/${priority}. ${existing.length} registrations already exist for that combination. While this is allowed it is not desired and when matching class requests occur, we will simply use the LAST registration we happen to have which can lead to unintended behavior. ***`);
33
+ if (priority > 0) {
34
+ // validate to make sure that the comabination of base class and key for the provided priority # is not already registered, if it is, then print a warning
35
+ const existing = registrations.filter(r => r.Priority === priority);
36
+ if (existing && existing.length > 0) {
37
+ console.warn(`*** ClassFactory.Register: Registering class ${subClass.name} for base class ${baseClass.name} and key/priority ${key}/${priority}. ${existing.length} registrations already exist for that combination. While this is allowed it is not desired and when matching class requests occur, we will simply use the LAST registration we happen to have which can lead to unintended behavior. ***`);
38
+ }
39
+ }
40
+ else if (priority === 0 || priority === null || priority === undefined) {
41
+ // when priority is not provided or is zero, which is logically the same, check to see what the highest earlier registration was and increment by 1
42
+ // this automatically makes the most recent registration higher, IF IT DIDN'T ALREADY have a priority explicitly set
43
+ let highestPriority = 0;
44
+ for (let i = 0; i < registrations.length; i++) {
45
+ if (registrations[i].Priority > highestPriority)
46
+ highestPriority = registrations[i].Priority;
47
+ }
48
+ // now set the priority to one higher than the highest priority we found
49
+ priority = highestPriority + 1;
37
50
  }
38
51
  // this combination of baseclass/key/priority is NOT already registered.
39
52
  let reg = new ClassRegistration();
@@ -1 +1 @@
1
- {"version":3,"file":"ClassFactory.js","sourceRoot":"","sources":["../src/ClassFactory.ts"],"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Ae,CAAC,SAAc,EAAE,MAAc,SAAS;QAC1D,IAAI,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QACtD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,qEAAqE;YACrE,IAAI,eAAe,GAAG,CAAC,CAAC;YACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,eAAe;oBACrC,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC9C,CAAC;YAED,sEAAsE;YACtE,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,eAAe,CAAC,CAAC;YAEpE,4JAA4J;YAC5J,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5GD,oCA4GC"}
package/dist/index.d.ts CHANGED
@@ -2,24 +2,29 @@ import * as MJ from './interface';
2
2
  import { Observable } from 'rxjs';
3
3
  import { ClassFactory } from './ClassFactory';
4
4
  import { ObjectCache } from './ObjectCache';
5
+ import { BaseSingleton } from './BaseSingleton';
5
6
  export { ClassFactory, ClassRegistration } from './ClassFactory';
6
7
  export * from './interface';
7
8
  export * from './util';
8
9
  export * from './ObjectCache';
10
+ export * from './BaseSingleton';
9
11
  /**
10
12
  * Global class used for coordinating events, creating class instances, and managing components across MemberJunction
11
13
  */
12
- export declare class MJGlobal {
14
+ export declare class MJGlobal extends BaseSingleton<MJGlobal> {
13
15
  private _eventsSubject;
14
16
  private _eventsReplaySubject;
15
17
  private _events$;
16
18
  private _eventsReplay$;
17
- private _globalObjectKey;
18
19
  private _components;
19
20
  private static _instance;
20
21
  private _classFactory;
21
22
  private _properties;
22
- constructor();
23
+ private constructor();
24
+ /**
25
+ * 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.
26
+ */
27
+ static get Instance(): MJGlobal;
23
28
  RegisterComponent(component: MJ.IMJComponent): void;
24
29
  /**
25
30
  * Resets the class to its initial state. Use very carefully and sparingly.
@@ -36,10 +41,6 @@ export declare class MJGlobal {
36
41
  * @returns
37
42
  */
38
43
  GetEventListener(withReplay?: boolean): Observable<MJ.MJEvent>;
39
- /**
40
- * 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.
41
- */
42
- static get Instance(): MJGlobal;
43
44
  /**
44
45
  * Returns the instance of ClassFactory you should use in your application. Access this via the MJGlobal.Instance.ClassFactory property.
45
46
  */
@@ -48,7 +49,6 @@ export declare class MJGlobal {
48
49
  * Global property bag
49
50
  */
50
51
  get Properties(): MJ.MJGlobalProperty[];
51
- GetGlobalObjectStore(): any;
52
52
  private _objectCache;
53
53
  /**
54
54
  * ObjectCache can be used to cache objects as needed by any application in memory. These objects are NOT persisted to disk or any other storage medium, so they are only good for the lifetime of the application
@@ -59,7 +59,7 @@ export declare class MJGlobal {
59
59
  * Decorate your class with this to register it with the MJGlobal class factory.
60
60
  * @param baseClass
61
61
  * @param key a string that is later used to retrieve a given registration - this should be unique for each baseClass/key combination, if multiple registrations exist for a given baseClass/key combination, the highest priority registration will be used to create class instances
62
- * @param priority the higher the number the more priority a registration has. If there are multiple registrations for a given combination of baseClass/key the highest priority registration will be used to create class instances
62
+ * @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used. Finally, if you do NOT provide this setting, the order of registrations will increment the priority automatically so dependency injection will typically care care of this. That is, in order for Class B, a subclass of Class A, to be registered properly, Class A code has to already have been loaded and therefore Class A's RegisterClass decorator was run. In that scenario, if neither Class A or B has a priority setting, Class A would be 1 and Class B would be 2 automatically. For this reason, you only need to explicitly set priority if you want to do something atypical as this mechanism normally will solve for setting the priority correctly based on the furthest descendant class that is registered.
63
63
  * @returns an instance of the class that was registered for the combination of baseClass/key (with highest priority if more than one)
64
64
  */
65
65
  export declare function RegisterClass(baseClass: any, key?: string, priority?: number): (constructor: Function) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AAEjC,OAAO,EAA0B,UAAU,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAqB,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAChE,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAE7B;;GAEG;AACH,qBAAa,QAAQ;IAEjB,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,oBAAoB,CAAkD;IAG9E,OAAO,CAAC,QAAQ,CAA8D;IAC9E,OAAO,CAAC,cAAc,CAAoE;IAE1F,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAW;IAEnC,OAAO,CAAC,aAAa,CAAoC;IAEzD,OAAO,CAAC,WAAW,CAA6B;;IAyBzC,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY;IAInD;;OAEG;IACI,KAAK;IAWZ;;;OAGG;IACI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO;IAKnC;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,GAAE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AO,CAAC,aAAa,CAAoC;IAEzD,OAAO,CAAC,WAAW,CAA6B;IAEhD,OAAO;IAIP;;OAEG;IACH,WAAkB,QAAQ,IAAI,QAAQ,CAErC;IAEM,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY;IAInD;;OAEG;IACI,KAAK;IAWZ;;;OAGG;IACI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO;IAKnC;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,GAAE,OAAe,GAAG,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC;IAI5E;;OAEG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAE7C;IAGD,OAAO,CAAC,YAAY,CAAkC;IACtD;;OAEG;IACH,IAAW,WAAW,IAAI,WAAW,CAEpC;CACJ;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAa,EAAE,QAAQ,GAAE,MAAU,iBACpD,QAAQ,UAIzC"}
package/dist/index.js CHANGED
@@ -15,49 +15,39 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.RegisterClass = exports.MJGlobal = exports.ClassRegistration = exports.ClassFactory = void 0;
18
- const util_1 = require("./util");
19
18
  const rxjs_1 = require("rxjs");
20
19
  const ClassFactory_1 = require("./ClassFactory");
21
20
  const ObjectCache_1 = require("./ObjectCache");
21
+ const BaseSingleton_1 = require("./BaseSingleton");
22
22
  var ClassFactory_2 = require("./ClassFactory");
23
23
  Object.defineProperty(exports, "ClassFactory", { enumerable: true, get: function () { return ClassFactory_2.ClassFactory; } });
24
24
  Object.defineProperty(exports, "ClassRegistration", { enumerable: true, get: function () { return ClassFactory_2.ClassRegistration; } });
25
25
  __exportStar(require("./interface"), exports);
26
26
  __exportStar(require("./util"), exports);
27
27
  __exportStar(require("./ObjectCache"), exports);
28
+ __exportStar(require("./BaseSingleton"), exports);
28
29
  /**
29
30
  * Global class used for coordinating events, creating class instances, and managing components across MemberJunction
30
31
  */
31
- class MJGlobal {
32
+ class MJGlobal extends BaseSingleton_1.BaseSingleton {
32
33
  constructor() {
34
+ super('MJGlobalInstance');
33
35
  // subjects for observables to handle eventing
34
36
  this._eventsSubject = new rxjs_1.Subject();
35
37
  this._eventsReplaySubject = new rxjs_1.ReplaySubject();
36
38
  // Convert the Subjects to Observables for public use.
37
39
  this._events$ = this._eventsSubject.asObservable();
38
40
  this._eventsReplay$ = this._eventsReplaySubject.asObservable();
39
- this._globalObjectKey = 'MJGlobalInstance';
40
41
  this._components = [];
41
42
  this._classFactory = new ClassFactory_1.ClassFactory();
42
43
  this._properties = [];
43
44
  this._objectCache = new ObjectCache_1.ObjectCache();
44
- if (MJGlobal._instance)
45
- return MJGlobal._instance;
46
- else {
47
- const g = (0, util_1.GetGlobalObjectStore)();
48
- if (g && g[this._globalObjectKey]) {
49
- MJGlobal._instance = g[this._globalObjectKey];
50
- return MJGlobal._instance;
51
- }
52
- // finally, if we get here, we are the first instance of this class, so create it
53
- if (!MJGlobal._instance) {
54
- MJGlobal._instance = this;
55
- // try to put this in global object store if there is a window/e.g. we're in a browser, a global object, we're in node, etc...
56
- if (g)
57
- g[this._globalObjectKey] = MJGlobal._instance;
58
- return this;
59
- }
60
- }
45
+ }
46
+ /**
47
+ * 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.
48
+ */
49
+ static get Instance() {
50
+ return super.getInstance('MJGlobalInstance');
61
51
  }
62
52
  RegisterComponent(component) {
63
53
  this._components.push(component);
@@ -89,14 +79,6 @@ class MJGlobal {
89
79
  GetEventListener(withReplay = false) {
90
80
  return withReplay ? this._eventsReplay$ : this._events$;
91
81
  }
92
- /**
93
- * 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.
94
- */
95
- static get Instance() {
96
- if (!MJGlobal._instance)
97
- MJGlobal._instance = new MJGlobal();
98
- return MJGlobal._instance;
99
- }
100
82
  /**
101
83
  * Returns the instance of ClassFactory you should use in your application. Access this via the MJGlobal.Instance.ClassFactory property.
102
84
  */
@@ -109,9 +91,6 @@ class MJGlobal {
109
91
  get Properties() {
110
92
  return this._properties;
111
93
  }
112
- GetGlobalObjectStore() {
113
- return (0, util_1.GetGlobalObjectStore)(); // wrap the function in a method here so that other modules can use it easily.
114
- }
115
94
  /**
116
95
  * ObjectCache can be used to cache objects as needed by any application in memory. These objects are NOT persisted to disk or any other storage medium, so they are only good for the lifetime of the application
117
96
  */
@@ -124,7 +103,7 @@ exports.MJGlobal = MJGlobal;
124
103
  * Decorate your class with this to register it with the MJGlobal class factory.
125
104
  * @param baseClass
126
105
  * @param key a string that is later used to retrieve a given registration - this should be unique for each baseClass/key combination, if multiple registrations exist for a given baseClass/key combination, the highest priority registration will be used to create class instances
127
- * @param priority the higher the number the more priority a registration has. If there are multiple registrations for a given combination of baseClass/key the highest priority registration will be used to create class instances
106
+ * @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used. Finally, if you do NOT provide this setting, the order of registrations will increment the priority automatically so dependency injection will typically care care of this. That is, in order for Class B, a subclass of Class A, to be registered properly, Class A code has to already have been loaded and therefore Class A's RegisterClass decorator was run. In that scenario, if neither Class A or B has a priority setting, Class A would be 1 and Class B would be 2 automatically. For this reason, you only need to explicitly set priority if you want to do something atypical as this mechanism normally will solve for setting the priority correctly based on the furthest descendant class that is registered.
128
107
  * @returns an instance of the class that was registered for the combination of baseClass/key (with highest priority if more than one)
129
108
  */
130
109
  function RegisterClass(baseClass, key = null, priority = 0) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","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,CAAC;IAClF,OAAO,UAAU,WAAqB;QAClC,iCAAiC;QACjC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnF,CAAC,CAAA;AACL,CAAC;AALD,sCAKC"}
package/dist/util.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * 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.
3
- * This function will return the appropriate object based on the environment.
2
+ * 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
3
+ * 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.
4
4
  * @returns
5
5
  */
6
6
  export declare function GetGlobalObjectStore(): typeof globalThis;
package/dist/util.js CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CleanJavaScript = exports.CleanJSON = exports.CopyScalarsAndArrays = exports.GetGlobalObjectStore = void 0;
4
4
  /**
5
- * 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.
6
- * This function will return the appropriate object based on the environment.
5
+ * 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
6
+ * 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.
7
7
  * @returns
8
8
  */
9
9
  function GetGlobalObjectStore() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/global",
3
- "version": "1.4.0",
3
+ "version": "1.5.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",