mirror of https://github.com/Hilbis/Hilbish
perf: remove listener directly from once emit instead of using off function
parent
a6f53b3c43
commit
c76337e5a4
|
@ -48,7 +48,7 @@ func (b *Bait) Emit(event string, args ...interface{}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, handle := range handles {
|
for idx, handle := range handles {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
b.callRecoverer(event, handle, err)
|
b.callRecoverer(event, handle, err)
|
||||||
|
@ -77,7 +77,7 @@ func (b *Bait) Emit(event string, args ...interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if handle.once {
|
if handle.once {
|
||||||
b.Off(event, handle)
|
b.removeListener(event, idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue