mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Propagate promise rejections so we show the fallback.
-Adds rejection support to Promise.All. -Makes promise.then() callback optional.
This commit is contained in:
parent
bf2ebd3714
commit
3dadde52dc
3 changed files with 31 additions and 14 deletions
15
src/core.js
15
src/core.js
|
@ -156,6 +156,10 @@ var Page = (function PageClosure() {
|
|||
var self = this;
|
||||
var promise = new Promise();
|
||||
|
||||
function reject(e) {
|
||||
promise.reject(e);
|
||||
}
|
||||
|
||||
var pageListPromise = new Promise();
|
||||
var annotationListPromise = new Promise();
|
||||
|
||||
|
@ -170,7 +174,7 @@ var Page = (function PageClosure() {
|
|||
this.idCounters);
|
||||
|
||||
var dataPromises = Promise.all(
|
||||
[contentStreamPromise, resourcesPromise]);
|
||||
[contentStreamPromise, resourcesPromise], reject);
|
||||
dataPromises.then(function(data) {
|
||||
var contentStream = data[0];
|
||||
var resources = data[1];
|
||||
|
@ -181,7 +185,8 @@ var Page = (function PageClosure() {
|
|||
opListPromise.then(function(data) {
|
||||
pageListPromise.resolve(data);
|
||||
});
|
||||
}
|
||||
},
|
||||
reject
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -195,7 +200,8 @@ var Page = (function PageClosure() {
|
|||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
reject
|
||||
);
|
||||
|
||||
Promise.all([pageListPromise, annotationListPromise]).then(
|
||||
|
@ -211,7 +217,8 @@ var Page = (function PageClosure() {
|
|||
Util.extendObj(pageData.dependencies, annotationData.dependencies);
|
||||
|
||||
promise.resolve(pageData);
|
||||
}
|
||||
},
|
||||
reject
|
||||
);
|
||||
|
||||
return promise;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue