@vercube/di 0.0.1-alpha.17 → 0.0.1-alpha.19

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,17 @@
1
+ /**
2
+ * Decorator that automatically executes the decorated method when the service or component
3
+ * is destroyed. Use this decorator to run cleanup logic like unregistering event listeners
4
+ * or clearing timers.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * class MyService {
9
+ * @Destroy()
10
+ * cleanup() {
11
+ * // Cleanup logic here
12
+ * }
13
+ * }
14
+ * ```
15
+ * @returns {Function} Decorator function that creates a DestroyDecorator instance
16
+ */
17
+ export declare function Destroy(): Function;
package/dist/index.cjs CHANGED
@@ -184,6 +184,22 @@ function Init() {
184
184
  return createDecorator(InitDecorator, {});
185
185
  }
186
186
 
187
+ //#endregion
188
+ //#region packages/di/src/Decorators/Destroy.ts
189
+ var DestroyDecorator = class extends BaseDecorator {
190
+ /**
191
+ * Called when decorator is destroyed. Executes the decorated method if it exists
192
+ * as a function on the instance. Used for cleanup tasks like unregistering
193
+ * listeners or clearing timers.
194
+ */
195
+ destroyed() {
196
+ if (typeof this.instance[this.propertyName] === "function") this.instance[this.propertyName]();
197
+ }
198
+ };
199
+ function Destroy() {
200
+ return createDecorator(DestroyDecorator, {});
201
+ }
202
+
187
203
  //#endregion
188
204
  //#region packages/di/src/Domain/ContainerEvents.ts
189
205
  var ContainerEvents = class {
@@ -582,6 +598,7 @@ var Container = class Container {
582
598
  //#endregion
583
599
  exports.BaseDecorator = BaseDecorator
584
600
  exports.Container = Container
601
+ exports.Destroy = Destroy
585
602
  Object.defineProperty(exports, 'IOC', {
586
603
  enumerable: true,
587
604
  get: function () {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./Common/BaseDecorators.js";
2
2
  export * from "./Decorators/Inject.js";
3
3
  export * from "./Decorators/InjectOptional.js";
4
4
  export * from "./Decorators/Init.js";
5
+ export * from "./Decorators/Destroy.js";
5
6
  export * from "./Domain/Container.js";
6
7
  export * from "./Types/IOCTypes.js";
7
8
  export * from "./Utils/Utils.js";
package/dist/index.mjs CHANGED
@@ -183,6 +183,22 @@ function Init() {
183
183
  return createDecorator(InitDecorator, {});
184
184
  }
185
185
 
186
+ //#endregion
187
+ //#region packages/di/src/Decorators/Destroy.ts
188
+ var DestroyDecorator = class extends BaseDecorator {
189
+ /**
190
+ * Called when decorator is destroyed. Executes the decorated method if it exists
191
+ * as a function on the instance. Used for cleanup tasks like unregistering
192
+ * listeners or clearing timers.
193
+ */
194
+ destroyed() {
195
+ if (typeof this.instance[this.propertyName] === "function") this.instance[this.propertyName]();
196
+ }
197
+ };
198
+ function Destroy() {
199
+ return createDecorator(DestroyDecorator, {});
200
+ }
201
+
186
202
  //#endregion
187
203
  //#region packages/di/src/Domain/ContainerEvents.ts
188
204
  var ContainerEvents = class {
@@ -579,4 +595,4 @@ var Container = class Container {
579
595
  };
580
596
 
581
597
  //#endregion
582
- export { BaseDecorator, Container, IOC, Identity, Init, Inject, InjectOptional, createDecorator, destroyContainer, destroyDecorators, initializeContainer, initializeDecorators };
598
+ export { BaseDecorator, Container, Destroy, IOC, Identity, Init, Inject, InjectOptional, createDecorator, destroyContainer, destroyDecorators, initializeContainer, initializeDecorators };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercube/di",
3
- "version": "0.0.1-alpha.17",
3
+ "version": "0.0.1-alpha.19",
4
4
  "description": "Dependencie Injection module for Vercube framework",
5
5
  "repository": "@vercube/di",
6
6
  "license": "MIT",