The code could be simplified to something like that,
function start(callback) {
one.on('ready', () => {
console.log('one server ready');
});
two.on('ready', () => {
console.log('two connection ready');
});
one.connect();
two.start();
}
I need to call that callback
, after both services getting to ready state. What's the best pattern for that?
Update: Ideas how to do that with RxJS are welcome :)