hello,
in my app i need to make sure that i unsubscribe to an EventEmitter when the page is changed, so i dont subscribe twice, when re-entering the page.
however when i try to subscribe again to the Emitter i get an “object unsubscribed” Error and when i already unsubscribed i get a promise execption in case the event fires.
is use the following code
in my provider i have:
private userDBlistener: EventEmitter<Object> = new EventEmitter<Object>();
//and later:
public getUserChangeListener():EventEmitter<Object>{
return this.userDBlistener;
}
in my page component:
private subscription:Subscription;
private listener:EventEmitter<Object>;
//and then in the constructor:
this.listener=this.myProvider.getUserChangeListener();
this.subscription = this.listener.subscribe(result => {
})
//and on unload:
ionViewWillUnload () {
this.listener.unsubscribe()
this.subscription=null
}
where is my mistake?
thanks a lot!