mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
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.
This commit is contained in:
committed by
Abdullah Atta
parent
4c541f3995
commit
e53cc648f0
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user