refactor: 重写useEventBus

This commit is contained in:
kailong321200875
2023-12-20 10:37:57 +08:00
parent 10745207e6
commit 80351516ce
4 changed files with 16 additions and 13 deletions

View File

@@ -8,7 +8,7 @@ interface Option {
const emitter = mitt()
export const useEmitt = (option?: Option) => {
export const useEventBus = (option?: Option) => {
if (option) {
emitter.on(option.name, option.callback)
@@ -18,6 +18,9 @@ export const useEmitt = (option?: Option) => {
}
return {
emitter
on: emitter.on,
off: emitter.off,
emit: emitter.emit,
all: emitter.all
}
}