convert solcw to use once

This commit is contained in:
Jonathan Rainville 2018-05-18 14:22:58 -04:00
parent c5c00fc3b4
commit a7be2cda26
1 changed files with 3 additions and 5 deletions

View File

@ -15,7 +15,7 @@ class SolcW {
load_compiler(done) { load_compiler(done) {
const self = this; const self = this;
if (this.compilerLoaded) { if (this.compilerLoaded) {
done(); return done();
} }
this.solcProcess = new ProcessLauncher({ this.solcProcess = new ProcessLauncher({
modulePath: utils.joinPath(__dirname, 'solcP.js'), modulePath: utils.joinPath(__dirname, 'solcP.js'),
@ -24,7 +24,7 @@ class SolcW {
}); });
this.solcProcess.send({action: "init", options: {}}); this.solcProcess.send({action: "init", options: {}});
this.solcProcess.on('result', 'loadedCompiler', () => { this.solcProcess.once('result', 'loadedCompiler', () => {
self.compilerLoaded = true; self.compilerLoaded = true;
done(); done();
}); });
@ -49,9 +49,7 @@ class SolcW {
} }
compile(jsonObj, done) { compile(jsonObj, done) {
const self = this; this.solcProcess.once('result', 'compilation', (msg) => {
this.solcProcess.on('result', 'compilation', (msg) => {
self.solcProcess.unsubscribeTo('result', 'compilation');
done(JSON.parse(msg.output)); done(JSON.parse(msg.output));
}); });