wait longer to arrive at #home but poll every 100ms

This commit is contained in:
Bruno Windels 2019-04-16 10:30:14 +02:00
parent be32414214
commit b01e126433
2 changed files with 18 additions and 3 deletions

View file

@ -201,4 +201,17 @@ module.exports = class RiotSession {
close() {
return this.browser.close();
}
async poll(callback, timeout) {
const INTERVAL = 100;
let waited = 0;
while(waited < timeout) {
await this.delay(INTERVAL);
waited += INTERVAL;
if (callback()) {
return true;
}
}
return false;
}
}