Update the waitOnEventOrTimeout helper function to handle internal events consistently with the rest of the viewer components (PR 11631 follow-up)

I overlooked this in PR 11631; sorry about that!

Also, ensure that `EventBus` instances *always* track "external" events using a boolean regardless of the actual option value.
This commit is contained in:
Jonas Jenwald 2020-03-05 12:00:44 +01:00
parent 25693c6b6d
commit 3ed1bc917d

View File

@ -716,7 +716,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
function handler(type) { function handler(type) {
if (target instanceof EventBus) { if (target instanceof EventBus) {
target.off(name, eventHandler); target._off(name, eventHandler);
} else { } else {
target.removeEventListener(name, eventHandler); target.removeEventListener(name, eventHandler);
} }
@ -729,7 +729,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
const eventHandler = handler.bind(null, WaitOnType.EVENT); const eventHandler = handler.bind(null, WaitOnType.EVENT);
if (target instanceof EventBus) { if (target instanceof EventBus) {
target.on(name, eventHandler); target._on(name, eventHandler);
} else { } else {
target.addEventListener(name, eventHandler); target.addEventListener(name, eventHandler);
} }
@ -829,7 +829,7 @@ class EventBus {
} }
eventListeners.push({ eventListeners.push({
listener, listener,
external: options ? options.external : false, external: (options && options.external) === true,
}); });
} }