Skip to content

Commit

Permalink
fix: emit 'unmount'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Jul 16, 2023
1 parent 4032bfa commit 4d17a2e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ref.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Input, ElementRef, OnChanges } from '@angular/core';
import { Input, ElementRef, OnChanges, OnDestroy } from '@angular/core';
import { Directive } from '@angular/core';

@Directive({
selector: '[refComponent]'
})
export class RefDirective implements OnChanges {
export class RefDirective implements OnChanges, OnDestroy {
@Input() data!: any
@Input() emit!: any

Expand All @@ -13,4 +13,8 @@ export class RefDirective implements OnChanges {
ngOnChanges() {
this.emit({ type: 'render', data: { ...this.data, element: this.el.nativeElement } })
}

ngOnDestroy() {
this.emit({ type: 'unmount', data: { element: this.el.nativeElement } })
}
}

0 comments on commit 4d17a2e

Please sign in to comment.