renamed Trigger arg to avoid confusion with the Handler type
This commit is contained in:
parent
393b461ea2
commit
1e480c5380
|
@ -145,16 +145,16 @@ func (h *Hook[T]) Length() int {
|
||||||
// with the specified event as an argument.
|
// with the specified event as an argument.
|
||||||
//
|
//
|
||||||
// Optionally, this method allows also to register additional one off
|
// Optionally, this method allows also to register additional one off
|
||||||
// handlers that will be temporary appended to the handlers queue.
|
// handler funcs that will be temporary appended to the handlers queue.
|
||||||
//
|
//
|
||||||
// NB! Each hook handler must call event.Next() in order the hook chain to proceed.
|
// NB! Each hook handler must call event.Next() in order the hook chain to proceed.
|
||||||
func (h *Hook[T]) Trigger(event T, oneOffHandlers ...func(T) error) error {
|
func (h *Hook[T]) Trigger(event T, oneOffHandlerFuncs ...func(T) error) error {
|
||||||
h.mu.RLock()
|
h.mu.RLock()
|
||||||
handlers := make([]func(T) error, 0, len(h.handlers)+len(oneOffHandlers))
|
handlers := make([]func(T) error, 0, len(h.handlers)+len(oneOffHandlerFuncs))
|
||||||
for _, handler := range h.handlers {
|
for _, handler := range h.handlers {
|
||||||
handlers = append(handlers, handler.Func)
|
handlers = append(handlers, handler.Func)
|
||||||
}
|
}
|
||||||
handlers = append(handlers, oneOffHandlers...)
|
handlers = append(handlers, oneOffHandlerFuncs...)
|
||||||
h.mu.RUnlock()
|
h.mu.RUnlock()
|
||||||
|
|
||||||
event.setNextFunc(nil) // reset in case the event is being reused
|
event.setNextFunc(nil) // reset in case the event is being reused
|
||||||
|
|
Loading…
Reference in New Issue