Skip to content

Commit

Permalink
Add default timeout to onWindowReady
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Brain committed Jul 22, 2016
1 parent 734144a commit 2c512ae
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ export function initOnReady() {
}
}

export function onWindowReady(win) {
return new promise.Promise(resolve => {
export function onWindowReady(win, timeout = 5000) {
return new promise.Promise((resolve, reject) => {

if (readyWindows.indexOf(win) !== -1) {
return resolve(win);
} else {
readyPromises.push({
win,
resolve
});

setTimeout(() => reject(new Error(`Bridge did not load after ${timeout}ms`)), timeout);
}
});
}

0 comments on commit 2c512ae

Please # to comment.