1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-03 23:50:33 +02:00

Mobile: Plugins: Fix event listener memory leak when disabling/uninstalling plugins (#10280)

Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
Henry Heino
2024-04-11 01:04:47 -07:00
committed by GitHub
parent 1812587970
commit c0c3b4d23e
8 changed files with 125 additions and 15 deletions

View File

@ -158,6 +158,22 @@ export class EventManager {
return this.emitter_.once(eventName, callback);
}
// For testing only; only applies to listeners registered with .on.
public listenerCounter_(event: EventName) {
const initialListeners = this.emitter_.listeners(event);
return {
getCountRemoved: () => {
const currentListeners = this.emitter_.listeners(event);
let countRemoved = 0;
for (const listener of initialListeners) {
if (!currentListeners.includes(listener)) {
countRemoved ++;
}
}
return countRemoved;
},
};
}
}
const eventManager = new EventManager();