Skip to content

Commit

Permalink
Update libs/src/LSPlugin.user.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
  • Loading branch information
2 people authored and andelf committed Apr 29, 2022
1 parent fc0f2b7 commit 9885dc6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions libs/src/LSPlugin.user.ts
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 9885dc6

Please sign in to comment.