pdf.js/test/types/main.ts
Jonas Jenwald 0e92f995c9 Re-factor the EventBus and isInAutomation handling (PR 11655 follow-up)
Rather than forcing the "regular" `EventBus` to check and handle `isInAutomation` for every `dispatch` call, we can take advantage of subclassing instead.
Hence this PR introduces a new `AutomationEventBus` class, which extends `EventBus`, and is used by the default viewer when `isInAutomation === true`.
2021-09-18 09:59:53 +02:00

24 lines
660 B
TypeScript

import { getDocument } from "pdfjs-dist";
import { EventBus } from "pdfjs-dist/web/pdf_viewer.component";
class MainTest {
eventBus: EventBus;
task: ReturnType<typeof getDocument> | undefined;
constructor(public file: string) {
this.eventBus = new EventBus();
}
loadPdf() {
this.task = getDocument("file://" + this.file);
return this.task.promise;
}
}
// This is actually never called, as the test only consists in compiling the file.
// The compilation will crawl through all files and make sure that the types are consistent.
const mt = new MainTest("../pdfs/basicapi.pdf");
mt.loadPdf().then(() => {
console.log("loaded");
});