Composables
useEmitAsProps
Convert a component's emit function into onXxx handler props, since Vue has no built-in emit forwarding.
Advanced. Primitive-authoring utility from
@vyui/core — most app code never calls this directly.Overview
import { useEmitAsProps } from '@vyui/core'
const emitsAsProps = useEmitAsProps(emit)
Converts a component's emit function into an object of onXxx handler props. Vue has no built-in "forward my emits to a child" mechanism (vuejs/core#5917), so this lets a wrapper spread both props and events onto an inner element transparently.
Signature
useEmitAsProps<Name extends string>(emit: (name: Name, ...args: any[]) => void): Record<string, (...args: any[]) => void>