remove listeners correctly

This commit is contained in:
Iuri Matias 2018-06-08 12:51:04 -04:00
parent 1b6ac99ea2
commit cdfa30ebd2
1 changed files with 14 additions and 7 deletions

View File

@ -119,14 +119,21 @@ class Test {
if (this.error) { if (this.error) {
return callback(this.error); return callback(this.error);
} }
this.events.once('ready', () => {
self.events.removeListener('deployError', () => {}); let errorCallback, readyCallback;
callback();
}); errorCallback = (err) => {
this.events.once('deployError', (err) => { self.events.removeListener('ready', readyCallback);
self.events.removeListener('ready', () => {});
callback(err); callback(err);
}); };
readyCallback = () => {
self.events.removeListener('deployError', errorCallback);
callback();
};
this.events.once('ready', readyCallback);
this.events.once('deployError', errorCallback);
} }
config(options, callback) { config(options, callback) {