plugins icon indicating copy to clipboard operation
plugins copied to clipboard

🧩 logseq.App.onRouteChanged

Open utterances-bot opened this issue 1 year ago • 2 comments

https://plugins-doc.logseq.com/logseq/App/onRouteChanged

utterances-bot avatar Jul 13 '24 21:07 utterances-bot

Currently, there is a bug. The callback is not returned every time. Therefore, it must be used in conjunction with onPageHeadActionsSlotted() to guarantee that it works.

const processing = false

logseq.App.onRouteChanged(async ()=> {
if(processing) return
setTimeout(() => { processing = false }, 1000)
processing = true
routeChanged()
})
logseq.App.onPageHeadActionsSlotted(async () => {
if(processing) return
setTimeout(() => { processing = false }, 1000)
processing = true
routeChanged()
})

const routeChanged = () => {
// Here

}

YU000jp avatar Jul 13 '24 21:07 YU000jp

🤔 Seems to work for me unless I am missing something. Is there a reproducible example where the callback is not triggered?

benjypng avatar Jul 14 '24 02:07 benjypng