1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Add a settled property, tracking the fulfilled/rejected stated of the Promise, to createPromiseCapability

This allows cleaning-up code which is currently manually tracking the state of the Promise of a `createPromiseCapability` instance.
This commit is contained in:
Jonas Jenwald 2019-02-02 13:10:06 +01:00
parent 291e62b41e
commit 22468817e1
4 changed files with 62 additions and 27 deletions

View file

@ -395,8 +395,7 @@ class BaseViewer {
});
});
let isOnePageRenderedResolved = false;
let onePageRenderedCapability = createPromiseCapability();
const onePageRenderedCapability = createPromiseCapability();
this.onePageRendered = onePageRenderedCapability.promise;
let bindOnAfterAndBeforeDraw = (pageView) => {
@ -407,8 +406,7 @@ class BaseViewer {
this._buffer.push(pageView);
};
pageView.onAfterDraw = () => {
if (!isOnePageRenderedResolved) {
isOnePageRenderedResolved = true;
if (!onePageRenderedCapability.settled) {
onePageRenderedCapability.resolve();
}
};