Unsubscribe from Observables with Destroy Subject

export class Component implements OnInit, OnDestroy {
private readonly destroySub = new Subject<void>();
ngOnInit() {
this.subject$
.pipe(takeUntil(this.destroySub))
.subscribe(a => console.log(a));
}
ngOnDestroy() {
this.destroySub.next();
this.destroySub.complete();
}
}