Update libs/src/LSPlugin.user.ts

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
Charlie
2022-04-29 18:19:02 +08:00
committed by Andelf
parent fc0f2b75c6
commit 9885dc64e0

View File

@@ -586,15 +586,21 @@ export class LSPluginUser
const handler = args[0]
caller[f](type, handler)
if (!isOff) {
that.App._installPluginHook(pid, type)
}
const unlisten = () => {
caller.off(type, handler)
if (!caller.listenerCount(type)) {
that.App._uninstallPluginHook(pid, type)
}
}
if (!isOff) {
that.App._installPluginHook(pid, type)
} else {
unlisten()
return
}
return () => {
caller.off(type, handler)
if (!caller.listenerCount(type)) {
that.App._uninstallPluginHook(pid, type)
}
return unlisten
}
}
}