Created
June 3, 2017 19:01
-
-
Save stevermeister/e38d65c1487f371e509b5da1d0be8ee9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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