framework-do-dede 1.0.28 → 1.0.30

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.
@@ -1,22 +1,19 @@
1
1
  import { Registry } from "../di/registry";
2
2
  import { StorageGateway } from "../protocols/StorageGateway";
3
- import { Log } from "../utils/Log";
4
3
  export function Storage(gatewayName) {
5
4
  return function (target, propertyKey) {
6
- while (!Registry.isLoaded()) {
7
- Log.info('Waiting for dependencies to be loaded...');
8
- }
9
- if (!Registry.has(gatewayName)) {
10
- throw new Error(`StorageGateway ${gatewayName} not registered`);
11
- }
12
- const GatewayClass = Registry.resolve(gatewayName);
13
- if (!(GatewayClass instanceof StorageGateway)) {
14
- throw new Error(`${gatewayName} is not a valid StorageGateway`);
15
- }
16
5
  const instanceSymbol = Symbol();
17
6
  Object.defineProperty(target, propertyKey, {
18
7
  get: function () {
19
8
  if (!this[instanceSymbol]) {
9
+ // Lazy load the gateway when the property is first accessed
10
+ if (!Registry.has(gatewayName)) {
11
+ throw new Error(`StorageGateway ${gatewayName} not registered`);
12
+ }
13
+ const GatewayClass = Registry.resolve(gatewayName);
14
+ if (!(GatewayClass instanceof StorageGateway)) {
15
+ throw new Error(`${gatewayName} is not a valid StorageGateway`);
16
+ }
20
17
  this[instanceSymbol] = GatewayClass;
21
18
  }
22
19
  return this[instanceSymbol];
@@ -12,7 +12,6 @@ declare class ComponentRegistry {
12
12
  classLoader<T>(target: new (...args: any[]) => T): T;
13
13
  inject(token: string): (target: any, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
14
14
  loaded(): void;
15
- isLoaded(): boolean;
16
15
  }
17
16
  export declare const Registry: ComponentRegistry;
18
17
  export {};
@@ -47,8 +47,5 @@ class ComponentRegistry {
47
47
  loaded() {
48
48
  this.isLoading = false;
49
49
  }
50
- isLoaded() {
51
- return !this.isLoading;
52
- }
53
50
  }
54
51
  export const Registry = ComponentRegistry.getInstance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framework-do-dede",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",