Open
Description
What problem does this feature solve?
Components might emit events that can not be statically analyzed. For example v-model
already does this with the update:[name || 'modelValue']
. Where name
is a v-model
argument. A custom event could look like this for example: change:[name]
where name
is derived from a component's prop.
What does the proposed API look like?
I think emits
should support these dynamic event names via guard callbacks:
<script>
export default {
emits: [(eventName) => /^change:/.test(eventName)] // will match any event listener that starts with `onChange:`
}
</script>
This could also work for event validations:
<script>
export default {
emits: [
{
name: (eventName) => /^change:/.test(eventName),
validate: (payload) => payload !== null,
}
]
}
</script>
Metadata
Metadata
Assignees
Labels
No labels
Activity