Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export class TestComponent {
constructor(private element : ElementRef) { }
interval: Subscription;
click: Subscription;
ngOnInit() {
this.intervalSubscription = Observable.interval(1000).subscribe(console.log);
this.clickSubscription = Observable.fromEvent(this.element.nativeElement, 'click').subscribe(console.log);
}
ngOnDestroy() {
this.intervalSubscription.unsubscribe();
this.clickSubscription.unsubscribe();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.