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) {
return callback(this.error);
}
this.events.once('ready', () => {
self.events.removeListener('deployError', () => {});
callback();
});
this.events.once('deployError', (err) => {
self.events.removeListener('ready', () => {});
let errorCallback, readyCallback;
errorCallback = (err) => {
self.events.removeListener('ready', readyCallback);
callback(err);
});
};
readyCallback = () => {
self.events.removeListener('deployError', errorCallback);
callback();
};
this.events.once('ready', readyCallback);
this.events.once('deployError', errorCallback);
}
config(options, callback) {