Answer the question
In order to leave comments, you need to log in
How to remove event listeners?
There is, for example, the following code.
class Account {
constructor(data) {
this.user = new User();
this.registerEvents();
this.logOn({login: this.user.login, password: this.user.password});
return this;
}
registerEvents() {
this.user.on('loggedOn', () => {
console.log('Login success!');
})
this.user.on('friendList', () => {
//... -- обработал данные, и хочу завершить работу
this.destruction();
})
}
logOn(data) {
this.user.logOn(data);
}
destruction() {
this.user.removeAllListeners();
this.user.logOff();
this.user = null;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question