From 236639dbb1972a6e929ddb81916f998b7017ce50 Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Mon, 16 Nov 2020 16:10:58 +0100 Subject: [PATCH] fix events triggering (#3454) --- src/core/EventBus.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/EventBus.js b/src/core/EventBus.js index 099d56d50f..cdf7139a69 100644 --- a/src/core/EventBus.js +++ b/src/core/EventBus.js @@ -92,13 +92,12 @@ function EventBus() { payload.type = type; handlers[type] = handlers[type].filter((item) => item); - const eventHandlers = handlers[type].filter(item => { - if (filters.streamId && item.streamId && item.streamId !== filters.streamId) return false; - if (filters.mediaType && item.mediaType && item.mediaType !== filters.mediaType) return false; - return true; + handlers[type].forEach(handler => { + if (!handler) return; + if (filters.streamId && handler.streamId && handler.streamId !== filters.streamId) return; + if (filters.mediaType && handler.mediaType && handler.mediaType !== filters.mediaType) return; + handler.callback.call(handler.scope, payload); }); - - eventHandlers.forEach(handler => handler && handler.callback.call(handler.scope, payload)); } function getHandlerIdx(type, listener, scope) {