title: Continuous polling of backend in vue.js
body: <p>I have a vue.js application, I'm integrating a 3rd party payment provider support. The way it works is the UI sends a payment request to the backend, the backend processes it, sends a request to the PSP, and gets back a redirect url. The frontend then needs to redirect to this url where the user authenticates with the PSP. </p>
  
  <p>Since the communication with the PSP is handled asynchronously on the backend, and I don't have two-way communication from backend to frontend, my frontend essentially needs to continuously poll the backend, asking "Do we have a redirect url yet?" over and over again.</p>
  
  <p>My first naive approach was to display a component (through v-if, when the "intitialize payment" request returns OK) and in the component I have this:</p>
  
  <pre><code> mounted() {
          setInterval(this.pollForRedirect, 1000);
      }
  </code></pre>
  
  <p>I did this so I could proceed with development, but it seems rather crude. Is there a best practice way to do this? Perhaps something native to vue?</p>
  
  <p>Should I be periodically increasing the polling interval, so that I'm not spamming the server if the processing is taking longer than expected? How do I stop the polling when the user gives up and navigates away form the component?</p>