-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Using provide/inject in a directive #5002
Comments
Set currentInstance before hook calls close: #5002
why this not to do? |
Any updates? In my application, I create smaller Vue apps for custom tooltips, and Inject API can significantly reduce the number of options I need to pass to my directive. |
I think it would be really useful to have a directive called E.g., <!-- A root component -->
<template>
<div>
<component
v-for="{ component, thing } in components"
:is="component"
v-provide:mykey="thing"
/>
...
</template>
<script setup>
import { provide } from 'vue'
...
const vProvide = {
created (el, binding) {
provide(binding.arg, binding.value)
}
}
...
</script> My specific use case at the moment is I need to provide siloed event buses for each component in the |
What problem does this feature solve?
Sometime you need to provide something from the root component, then the
provide
is really useful for this:And sometime you want to inject
my-stuff
into a directive:For now you can't do that. And yes, there are many workarounds to solve this problem, but I think this, lets say, is the most decent way to perform.
Any possibility?
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: