janniks / vue-notion

A fast Vue renderer for Notion pages
https://vue-notion.now.sh
Other
873 stars 61 forks source link

Watch for render changes, getPageBlocks done #142

Open spyderdsn opened 6 months ago

spyderdsn commented 6 months ago

How to know when page blocks are done and DOM is fully updated? Is there any callback function?

const { data: blockMap } = useAsyncData('page_nuxt', () => $notion.getPageBlocks(pageUrl))

at the moment I'm using timeout but it is not always reliable:

await nextTick(() => {
    setTimeout(() => {
      document.body.scrollTop = 0 // For Safari
      document.documentElement.scrollTop = 0
      animations.apply('.notion', 'animated fade-in-right')
      isLoading.value = false
    }, 1500)
  })
janniks commented 6 months ago

Hmm, I assume as soon as the Promise resolves (the await finishes) all blocks are in the response. The helper (API call collects all the blocks). Maybe I’m missing something… 🤔