How to check when observable has completed

I have a simple countdown timer in angular 4

import {Observable} from ‘rxjs/Observable’;
import ‘rxjs/add/observable/timer’;
import ‘rxjs/add/operator/map’;
import ‘rxjs/add/operator/take’;

counter = 60;
enableButton:boolean = false;

this.countDown = Observable.timer(0,1000).take(this.counter).map(() => –
I want to make enableButton boolean true when this observable has been completed.

How should I write that code? Please Help

Here is a plunker link, which I am using in my project

An Observable emits three possible events: next, which is a value; error, and complete. Are you subscribing? If so, you can just have three functions (like a try/catch but there are three of them).

someObservable.subscribe( val => handleValue, err => handleError, complete => handleComplete);

1 Like