Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: do not unsub all `once` events on publish

Abdullah Attae53cc648f084
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;