i have multiple functions that have subscriptions. First i have it on the ngOnInit(), then i have another function called onSelectVillain(). So my question is this possible that you could just use this.subscription.unsubscribe(). Or should i make declare another subscription?
subscription: Subscription;
ngOnInit() {
this.subscription = this.heroService.getHeroes()
.subscribe(
heroes => this.heroes = heroes,
error => this.errorMessage = <any>error);
}
onSelectVillain(event) {
this.subscription = this.villainService.getVillains()
.subscribe(
.....
}
ngOnDestroy(){
this.subscription.unsubscribe()
}