GlobalThis.ts 518 B

1234567891011121314151617181920
  1. export class GlobalContext {
  2. private constructor() {}
  3. private static instance: GlobalContext;
  4. private _objects = new Map<string, Object>();
  5. public static getContext(): GlobalContext {
  6. if (!GlobalContext.instance) {
  7. GlobalContext.instance = new GlobalContext();
  8. }
  9. return GlobalContext.instance;
  10. }
  11. getObject(value: string): Object | undefined {
  12. return this._objects.get(value);
  13. }
  14. setObject(key: string, objectClass: Object): void {
  15. this._objects.set(key, objectClass);
  16. }
  17. }