mirror of https://github.com/logseq/logseq
fix(plugin): return clear handle for hooks api
parent
6e6aa5819a
commit
f4bb7bfa9b
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@logseq/libs",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"description": "Logseq SDK libraries",
|
||||
"main": "dist/lsplugin.user.js",
|
||||
"typings": "index.d.ts",
|
||||
|
|
|
@ -402,7 +402,6 @@ export class LSPluginUser
|
|||
console.warn(e)
|
||||
}
|
||||
|
||||
|
||||
callback && callback.call(this, baseInfo)
|
||||
} catch (e) {
|
||||
console.error(`${this._debugTag} [Ready Error]`, e)
|
||||
|
@ -575,13 +574,15 @@ export class LSPluginUser
|
|||
const handler = args[0]
|
||||
caller[f](type, handler)
|
||||
|
||||
if (isOff) {
|
||||
return () => {
|
||||
caller.off(type, handler)
|
||||
if (!isOff) {
|
||||
that.App._installPluginHook(pid, type)
|
||||
}
|
||||
|
||||
return () => {
|
||||
caller.off(type, handler)
|
||||
if (!caller.listenerCount(type)) {
|
||||
that.App._uninstallPluginHook(pid, type)
|
||||
}
|
||||
} else {
|
||||
return that.App._installPluginHook(pid, type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue