Skip to content
Snippets Groups Projects
Commit 19c43238 authored by jojohoch's avatar jojohoch
Browse files

[player] Unsubscribe from subject on destroy in ScrollToIndexDirective

parent 41da19e2
No related branches found
No related tags found
No related merge requests found
Pipeline #40163 failed
import { import {
Directive, ElementRef, Input, OnInit Directive, ElementRef, Input, OnDestroy, OnInit
} from '@angular/core'; } from '@angular/core';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@Directive({ @Directive({
selector: '[aspectScrollToIndex]' selector: '[aspectScrollToIndex]'
}) })
export class ScrollToIndexDirective implements OnInit { export class ScrollToIndexDirective implements OnInit, OnDestroy {
@Input() selectIndex!: Subject<number>; @Input() selectIndex!: Subject<number>;
@Input() index!: number; @Input() index!: number;
private ngUnsubscribe = new Subject<void>();
constructor(private elementRef: ElementRef) {} constructor(private elementRef: ElementRef) {}
ngOnInit(): void { ngOnInit(): void {
...@@ -19,4 +21,9 @@ export class ScrollToIndexDirective implements OnInit { ...@@ -19,4 +21,9 @@ export class ScrollToIndexDirective implements OnInit {
} }
}); });
} }
ngOnDestroy(): void {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment