Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add component guards onBeforeRouteLeave and onBeforeRouteUpdate #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nolde
Copy link

@nolde nolde commented Mar 19, 2022

BREAKING CHANGE: @vue/composition-api minimal version required is 1.0.0

There is no other tests in the project, so I've created none. I can do it if required.

I did not test this yet, but it should work, judging by the code found here.

Will test it later, but you can pre-review it until I can get to testing.

…date`

- update documentation
- upgrade required `@vue/composition-api` for proper `.proxy` usage

BREAKING CHANGE: `@vue/composition-api` minimal version required is `1.0.0`
@davidmeirlevy
Copy link
Contributor

Hi!

thanks for this PR!
if you can create the first tests that would be great, I didn't do it so far because the project was very small.

Adds a navigation guard that triggers whenever the component for the current location is about to be left. Similar to `beforeRouteUpdate` and `beforeRouteLeave` but can be used in any component. The guard is removed when the component is unmounted.

```js
import { onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router-compositions'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the naming convention for hooks should be "useX", so please just provide the hooks names using that convention. 🙏

Copy link
Author

@nolde nolde Mar 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for hooks... the hooks coming from vue-router itself are called onBeforeRouteLeave and onBeforeRouteUpdate, as can be seen on their documentation.

I named them the same because they are, basically, drop ins for people who cannot migrate to vue 3 + vue-router 4 yet. That way, when they migrate, they just have to change from vue-router-compositions to vue-router, and nothing else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants