Can i do better than this, i don't like using timeout :/ but i found no other way
const gui = require('nw.gui');
gui.Window.open('index.html');
const setupExecutors = (window) => {
return new Promise((resolve, reject) => {
const executors = [];
window.getAll((pages) => {
// this is juste to add other data that will be pushed to executors
pages.forEach((page) => {
executors.push(page);
});
});
setTimeout(() => {
if(executors.length === poolExecutor) {
resolve(executors);
} else {
reject('Failed to setup executors !');
}
}, 200);
})
}
setupExecutors(gui.Window).then((executors) => {
console.log('executors.length: ', executors.length);
})