{"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';\nexport { Features } from '@ngx-cocktail/common';\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;MAGpB,SAAS,CAAA;AAD/B,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,EAAA,CAAgB,GAAG,IAAI,OAAO,EAAE;QACxC,IAAA,CAAA,UAAU,GAAG,IAAI,CAAC,cAAc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