Subscribe can take three params:
subscribe( (x)=> console.log(x), err=> console.log(err), ()=> console.log('complete') );
If we want to stop the progame at some condition, so we need to notify complete function, which is the third param in subscribe.
Observable.combineLatest( timer$, input$, (timer, input)=> ({count: timer.count, text: input}) ) .takeWhile((data)=> data.count <= 3) .filter((data)=> data.count === parseInt(data.text)) .subscribe( (x)=> console.log(x), err=> console.log(err), ()=> console.log('complete') );
We can use takeWhile() function to end the program, so after the count = 3, "complete" will logout