fix(core): push emit handlers into listeners set
This commit is contained in:
@@ -69,7 +69,8 @@ export function useHooks(emit: (...args: any[]) => void, hooks: Ref<FlowHooks>)
|
||||
emit(key, data)
|
||||
}
|
||||
|
||||
value.on(listener)
|
||||
// push into fns instead of using `on` to avoid overwriting default handlers - the emits should be called in addition to the default handlers
|
||||
value.fns.add(listener)
|
||||
|
||||
tryOnScopeDispose(() => {
|
||||
value.off(listener)
|
||||
|
||||
@@ -8,6 +8,7 @@ import { tryOnScopeDispose } from '@vueuse/core'
|
||||
*/
|
||||
export interface EventHookExtended<T> extends EventHook<T> {
|
||||
hasListeners: () => boolean
|
||||
fns: Set<(param: T) => void>
|
||||
}
|
||||
|
||||
export function createExtendedEventHook<T = any>(defaultHandler?: (param: T) => void): EventHookExtended<T> {
|
||||
@@ -50,5 +51,6 @@ export function createExtendedEventHook<T = any>(defaultHandler?: (param: T) =>
|
||||
off,
|
||||
trigger,
|
||||
hasListeners,
|
||||
fns,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user