From e53cc648f084b8fc2bb879af25ac4e2344e05342 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Tue, 28 Feb 2023 12:09:50 +0500 Subject: [PATCH] core: do not unsub all `once` events on publish this was a stupid bug where publishing any type of event would unsubscribe all events that had once set to true. --- packages/core/utils/event-manager.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/utils/event-manager.js b/packages/core/utils/event-manager.js index e1c1f9242..dbea12a2a 100644 --- a/packages/core/utils/event-manager.js +++ b/packages/core/utils/event-manager.js @@ -53,16 +53,20 @@ class EventManager { publish(name, ...args) { this._registry.forEach((props, handler) => { - if (props.name === name) handler(...args); - if (props.once) this._registry.delete(handler); + if (props.name === name) { + handler(...args); + if (props.once) this._registry.delete(handler); + } }); } async publishWithResult(name, ...args) { const handlers = []; this._registry.forEach((props, handler) => { - if (props.name === name) handlers.push(handler); - if (props.once) this._registry.delete(handler); + if (props.name === name) { + handlers.push(handler); + if (props.once) this._registry.delete(handler); + } }); if (handlers.length <= 0) return true;