( instance: ComponentInternalInstance, event: string | string[], fn: Function, )
| 24 | } |
| 25 | |
| 26 | export function on( |
| 27 | instance: ComponentInternalInstance, |
| 28 | event: string | string[], |
| 29 | fn: Function, |
| 30 | ): ComponentPublicInstance | null { |
| 31 | if (isArray(event)) { |
| 32 | event.forEach(e => on(instance, e, fn)) |
| 33 | } else { |
| 34 | if (event.startsWith('hook:')) { |
| 35 | assertCompatEnabled( |
| 36 | DeprecationTypes.INSTANCE_EVENT_HOOKS, |
| 37 | instance, |
| 38 | event, |
| 39 | ) |
| 40 | } else { |
| 41 | assertCompatEnabled(DeprecationTypes.INSTANCE_EVENT_EMITTER, instance) |
| 42 | } |
| 43 | const events = getRegistry(instance) |
| 44 | ;(events[event] || (events[event] = [])).push(fn) |
| 45 | } |
| 46 | return instance.proxy |
| 47 | } |
| 48 | |
| 49 | export function once( |
| 50 | instance: ComponentInternalInstance, |
no test coverage detected