can cancel promis

This commit is contained in:
2022-09-07 21:24:07 +02:00
parent b0d52afc00
commit cdd47327b1
2 changed files with 72 additions and 23 deletions
+39 -8
View File
@@ -12,17 +12,48 @@ function delay(delayInms) {
}
const mongoManager = new MongoManager();
mongoManager.connect()
let excelUtil = new ExcelUtil();
let contactList = excelUtil.readContacts();
(async () => {
// Connect to the device.
const [device] = await android.devices();
async function startBook(contactPojo, device) {
console.log(`Model: ${device.model()}`);
console.log(`Serial: ${device.serial()}`);
let commandor = new CommandorPage(contactList[3], device, mongoManager);
//read contacts form excel
await commandor.loadPage();
// Take screenshot of the whole device.
})();
let commandor = new CommandorPage(contactPojo, device, mongoManager);
//read contacts form excel
return await commandor.loadPage();
}
mongoManager.connect().then(r => console.log("mongo connected"))
async function printFiles() {
let devices = await android.devices();
await contactList.reduce(async (promise, contactPojo) => {
// This line will wait for the last async function to finish.
// The first iteration uses an already resolved Promise
// so, it will immediately continue.
await promise;
const contents = await startBook(contactPojo, devices[0]);
console.log(contents);
}, Promise.resolve());
}
(async () => {
printFiles()
})()
// android.devices().then((device_list) => {
// contactList.forEach((contactPojo) => {
// device_list.forEach((device) => {
// (async () => {
// await startBook(contactPojo, device)
// })()
// }
// )
// }
// )
// })