-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
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
Modifier to propagate/forward events to parent #9325
Comments
why not just I do like having a dedicated keyword though |
@lopugit because passing the whole array in one argument would make users handle the same event differently in different components, plus it is a little redundant. |
Isn't propagating arguments upwards what you want??
…On Wed., 16 Jan. 2019, 6:50 pm Vontus ***@***.*** wrote:
@lopugit <https://github.com/lopugit> because passing the whole array in
one argument would make users handle the same event differently in
different components, plus it is a little redundant.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9325 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AM_3BshACHBnU8nluMZLTLrOAGxiD6NEks5vDtmzgaJpZM4aAyIG>
.
|
You should be able to use the spread operator, ala:
|
@laander That solves the issue with the arguments, but I think a modifier to let Vue do it would be a nice addition. I think this modifier can be specially useful for wrapper components that need to emit most events they receive from their child component. |
I think this would be a cool addition |
+1 |
|
nice!!! OPEN SOURCE FTW |
That's also great for keeping the whole app more maintainable |
I believe you can achieve this by adding |
I didn't know that, thank you for the tip! The only problem I find is that you aren't able to select which events are being propagated to the parent, it just forwards every event from the nested component. |
@Vontus you can! Just wrap $listeners with your own computed property that filters the keys |
Hey, not considered anymore? |
Is anyone working on this? I'd love to see this feature |
I posted the same request back in 2018 for a In Svelte you can just do |
It seems like |
@bryanmylee Listeners are now in |
What problem does this feature solve?
Currently, and as far as I know, if we want to propagate an event fired by a child component to the parent (the child's grandparent) we need to $emit the event again, and we need to pass all the arguments one more time. This can become a problem, for example, if the event has a variable number of arguments because we need to specify them manually or pass the whole array as a new argument.
The current way would be something like
What does the proposed API look like?
And if we want to both handle the event and propagate it to the parent, we would use
EDIT: Maybe since .propagate may be confused with the function .stopPropagation(), a better term could be simply .emit
The text was updated successfully, but these errors were encountered: