You've already forked joplin
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:
@ -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();
|
||||
|
Reference in New Issue
Block a user