I'm relatively new to using Observables and Typescript, so bear with me if this question sounds like a beginner one. I am trying to create a simple timer but I want the ability to unsubscribe all subscribers from within the timer itself.
Here is what my current code looks like:
import { Observable } from "rxjs/Rx";
export class Timer {
private interval: number;
private ticker: Observable<any>;
constructor() {
this.interval = 1000; // Miliseconds
this.ticker = Observable.interval(this.interval).timeInterval();
}
complete() {
// Unsubscribe all listeners here
}
}
Any ideas on how I can achieve unsubscribing all listeners from the complete
method?