( instance: ComponentInternalInstance, event?: string | string[], fn?: Function, )
| 61 | } |
| 62 | |
| 63 | export function off( |
| 64 | instance: ComponentInternalInstance, |
| 65 | event?: string | string[], |
| 66 | fn?: Function, |
| 67 | ): ComponentPublicInstance | null { |
| 68 | assertCompatEnabled(DeprecationTypes.INSTANCE_EVENT_EMITTER, instance) |
| 69 | const vm = instance.proxy |
| 70 | // all |
| 71 | if (!event) { |
| 72 | eventRegistryMap.set(instance, Object.create(null)) |
| 73 | return vm |
| 74 | } |
| 75 | // array of events |
| 76 | if (isArray(event)) { |
| 77 | event.forEach(e => off(instance, e, fn)) |
| 78 | return vm |
| 79 | } |
| 80 | // specific event |
| 81 | const events = getRegistry(instance) |
| 82 | const cbs = events[event!] |
| 83 | if (!cbs) { |
| 84 | return vm |
| 85 | } |
| 86 | if (!fn) { |
| 87 | events[event!] = undefined |
| 88 | return vm |
| 89 | } |
| 90 | events[event!] = cbs.filter(cb => !(cb === fn || (cb as any).fn === fn)) |
| 91 | return vm |
| 92 | } |
| 93 | |
| 94 | export function emit( |
| 95 | instance: ComponentInternalInstance, |
no test coverage detected