Skip to content

Instantly share code, notes, and snippets.

@stevermeister
Created June 3, 2017 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevermeister/e38d65c1487f371e509b5da1d0be8ee9 to your computer and use it in GitHub Desktop.
Save stevermeister/e38d65c1487f371e509b5da1d0be8ee9 to your computer and use it in GitHub Desktop.
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