Modifier to propagate/forward events to parent
See original GitHub issueWhat 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
@blur="$emit('blur')"
@create="$emit('create', arguments[0])"
@input="$emit('input', arguments[0], arguments[1])"
What does the proposed API look like?
@blur.propagate
@create.propagate
@input.propagate
And if we want to both handle the event and propagate it to the parent, we would use
@input.propagate="someFunction"
EDIT: Maybe since .propagate may be confused with the function .stopPropagation(), a better term could be simply .emit
Issue Analytics
- State:
- Created 5 years ago
- Reactions:73
- Comments:18
Top Results From Across the Web
qt - How do I propagate a mousePressEvent() to a group of ...
Calling accept() in mousePressEvent will prevent the event from being propagated to the child object. I believe this is true, but the parent...
Read more >List of Compose modifiers - Jetpack - Android Developers
Creates a modifier that controls the drawing order for the children of the same layout parent. Focus. Scope: Any. Modifier ...
Read more >How to raise base class events in derived classes - C# ...
The following simple example shows the standard way to declare events in a base class so that they can also be raised from...
Read more >Events / Event forwarding • Svelte Tutorial
Unlike DOM events, component events don't bubble. If you want to listen to an event on some deeply nested component, the intermediate components...
Read more >Emit an event from a child to parent component in Angular 9
When the event is emitted upward to the parent component, the parentEventHandlerFunction function (which we will code next) will be called. Notice the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
nice!!! OPEN SOURCE FTW