Change the createPromiseCapability helper function into a PromiseCapability class

This is not only slightly more compact, but it also simplifies the handling of the `settled` getter.
This commit is contained in:
Jonas Jenwald 2022-03-07 17:41:41 +01:00
parent f9c2a8d437
commit 317abd6d07
24 changed files with 117 additions and 122 deletions

View file

@ -14,7 +14,7 @@
*/
import { BaseTreeViewer } from "./base_tree_viewer.js";
import { createPromiseCapability } from "pdfjs-lib";
import { PromiseCapability } from "pdfjs-lib";
import { SidebarView } from "./ui_utils.js";
/**
@ -89,7 +89,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
* @private
*/
_dispatchEvent(outlineCount) {
this._currentOutlineItemCapability = createPromiseCapability();
this._currentOutlineItemCapability = new PromiseCapability();
if (
outlineCount === 0 ||
this._pdfDocument?.loadingParams.disableAutoFetch
@ -308,7 +308,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
if (this._pageNumberToDestHashCapability) {
return this._pageNumberToDestHashCapability.promise;
}
this._pageNumberToDestHashCapability = createPromiseCapability();
this._pageNumberToDestHashCapability = new PromiseCapability();
const pageNumberToDestHash = new Map(),
pageNumberNesting = new Map();