0

There is a list and a detail page. If I click the Back button on the browser on the Details page, the asynchronous function will act, which will change the state. What I want is that when this asynchronous function works successfully, it goes back to the list page, and on the list page, I want to get a list with an updated status. However, unlike what I thought, there are cases where the list is loaded first and the status is updated after that. How can we solve this problem? I use svelte.

  

  onMount(async () => {
    if (!accessToken) {
      navigate('/login')
      return
    }
    window.addEventListener('popstate', async (event) => {
      
      await resetData()

      history.pushState(null, '', config.HOME_PATHNAME)
    })
  })

Any advice or response is always welcome Thank you

Jay0813
  • 39
  • 4
  • 2
    sveltekit has a "beforeNavigate" function but this does not support async operations. There is a good explanation here: https://stackoverflow.com/questions/72983111/call-endpoint-within-sveltekit-beforenavigate-function-and-cancel-navigation-bas – justintimeza Apr 12 '23 at 14:20

0 Answers0