{"version":3,"file":"ngx-cocktail-destroyable.mjs","sources":["../../../projects/destroyable/src/lib/destroyable.class.ts","../../../projects/destroyable/src/lib/destoyable.feature.ts","../../../projects/destroyable/src/public-api.ts","../../../projects/destroyable/src/ngx-cocktail-destroyable.ts"],"sourcesContent":["import { Directive } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { Destroyable } from './destroyable.interface';\n\nconst destroySubject = Symbol('destroyed');\n\n@Directive()\nexport abstract class Destroyed implements Destroyable {\n  private readonly [destroySubject] = new Subject();\n  readonly destroyed$ = this[destroySubject].asObservable();\n\n  ngOnDestroy() {\n    this[destroySubject].next(null);\n    this[destroySubject].complete();\n  }\n}\n","import { OnDestroy, ɵDirectiveDef, Type } from '@angular/core';\nimport { Writable } from '@ngx-cocktail/common';\n\nimport { Destroyed } from './destroyable.class';\nimport { Destroyable } from './destroyable.interface';\n\nexport function DestroyableFeature() {\n  return <T extends Type<unknown>>(\n    directiveDef: Writable<ɵDirectiveDef<T>>\n  ) => {\n    const { factory, type } = directiveDef;\n    const { ngOnDestroy } = directiveDef.type.prototype as OnDestroy;\n\n    directiveDef.factory = () => {\n      const instance = factory?.(type) as T;\n      const destroyed = Reflect.construct(Destroyed, []) as Destroyable;\n\n      Object.assign(instance, destroyed);\n\n      directiveDef.type.prototype.ngOnDestroy = function () {\n        ngOnDestroy?.call(this);\n        destroyed.ngOnDestroy?.call(this);\n      };\n\n      return instance;\n    };\n  };\n}\n","/*\n * Public API Surface of destroyable\n */\n\nexport * from './lib';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAIA,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;MAGrB,SAAS,CAAA;AAD/B,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,EAAA,CAAgB,GAAG,IAAI,OAAO,EAAE,CAAC;QACzC,IAAU,CAAA,UAAA,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,YA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