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

[plugin]How can a plugin know app mount/unmount ? #4516

Closed
agileago opened this issue Sep 3, 2021 · 4 comments · Fixed by #4619
Closed

[plugin]How can a plugin know app mount/unmount ? #4516

agileago opened this issue Sep 3, 2021 · 4 comments · Fixed by #4619
Assignees
Labels
✨ feature request New feature or request

Comments

@agileago
Copy link

agileago commented Sep 3, 2021

What problem does this feature solve?

I want to clear some effect when app unmount. but I can't find the app api to do this. now i only hack rootProps to add onVnodeBeforeUnmount prop to achieve it. but i find vue2 has event dispatch

https://github.com/vuejs/vue-router/blob/dev/src/index.js#L98

What does the proposed API look like?

app maybe should expose some function to achieve it

@LinusBorg
Copy link
Member

Your plugin can expose a bootstrapping function / mixin that can be added to the root component.

That would be the usual way so far. Personally I'm not a friend of further increasing the Plugin API surface.

@yyx990803
Copy link
Member

There's currently no API to do this. For now wrapping the app's unmount function would probably be the cleanest way to do it.

@yyx990803
Copy link
Member

I think an easy improvement is allowing a plugin function to return a "cleanup" callback.

@yyx990803 yyx990803 added the ✨ feature request New feature or request label Sep 5, 2021
@agileago
Copy link
Author

agileago commented Sep 6, 2021

I think an easy improvement is allowing a plugin function to return a "cleanup" callback.

yes. perfect design

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✨ feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants