Tried to make a simple timer and need to break it on some if condition. But always got an error EXCEPTION: timer.unsubscribe is not a function.
if
EXCEPTION: timer.unsubscribe is not a function
It should be:
let timer:any = Observable.timer(0,1000); let subscription = timer.subscribe(data => { console.log(this.itemsRatedList); if(data == 5) subscription.unsubscribe(); });
You can't unsubscribe an Observable, only a Subscription.
unsubscribe
Observable
Subscription
Plunker example