mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
[api-minor] Deprecate getGlobalEventBus
and update the "viewer components" examples accordingly
To avoid outright breaking third-party usages of the "viewer components" the `getGlobalEventBus` functionality is left intact, but a deprecation message is printed if the function is invoked. The various examples are updated to *explicitly* initialize an `EventBus` instance, and provide that when initializing the relevant viewer components.
This commit is contained in:
parent
965ebe63fd
commit
9a437a158f
16 changed files with 68 additions and 34 deletions
|
@ -757,9 +757,8 @@ const animationStarted = new Promise(function(resolve) {
|
|||
});
|
||||
|
||||
/**
|
||||
* Simple event bus for an application. Listeners are attached using the
|
||||
* `on` and `off` methods. To raise an event, the `dispatch` method shall be
|
||||
* used.
|
||||
* Simple event bus for an application. Listeners are attached using the `on`
|
||||
* and `off` methods. To raise an event, the `dispatch` method shall be used.
|
||||
*/
|
||||
class EventBus {
|
||||
constructor({ dispatchToDOM = false } = {}) {
|
||||
|
@ -832,6 +831,9 @@ class EventBus {
|
|||
|
||||
let globalEventBus = null;
|
||||
function getGlobalEventBus(dispatchToDOM = false) {
|
||||
console.error(
|
||||
"getGlobalEventBus is deprecated, use a manually created EventBus instance instead."
|
||||
);
|
||||
if (!globalEventBus) {
|
||||
globalEventBus = new EventBus({ dispatchToDOM });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue