title: Vue Router Composition API OnBeforeRouteLeave invalid navigation guard
body: <p>I need to show a modal before the user leave a route and ask for confirmation. Based on that confirmation the user can leave the route. The problem is that the confirmation comes as a promise and <code>OnBeforeRouteLeave</code> expects a boolean return that i cannot do inside of <code>.then()</code>. I couldn't find anything on their API but is there a method i can use? Like <code>next()</code> that worked in the previous version of vue router or maybe a more suitable hook for this case?</p>
  <pre><code>onBeforeRouteLeave((to, from, next) =&gt; {
        if(!isEqual(store.getters['product/getProduct'], initialState)) {
          Swal.fire({
            title: 'You want to leave the page?',
            text: `There are unsaved changes that will be lost.`,
            icon: 'warning',
            showCancelButton: true,
            buttonsStyling: false,
            cancelButtonColor: '#d33',
            confirmButtonColor: '#3085d6',
            confirmButtonText: 'Yes, leave!',
            customClass: {
              confirmButton: &quot;btn font-weight-bold btn-light-primary&quot;,
              cancelButton: &quot;btn font-weight-bold btn-light-primary&quot;,
            },
            heightAuto: false
          }).then((result) =&gt; {
            if (result.isConfirmed) {
              store.commit('product/resetState')
              next()
            }
  
          })
        }
        return false
      })
  </code></pre>
  <p>Update:</p>
  <p>On the source code it says:</p>
  <blockquote>
  <p>Add a navigation guard that triggers whenever the component for the current location is about to be left. Similar to beforeRouteLeave but can be used in any component. The guard is removed when the component is unmounted.
  On <code>beforeRouteLeave</code> there is a <code>next</code> function and yet when i use it i get:</p>
  </blockquote>
  <blockquote>
  <p>Uncaught (in promise) Error: Invalid navigation guard</p>
  </blockquote>