fix: make RegisterCritical variadic for API consistency with RegisterCriticalUntilLatest
This commit is contained in:
@@ -139,10 +139,12 @@ func (l *Loop) RegisterLow(eventType reflect.Type, hv reflect.Value, critical bo
|
|||||||
|
|
||||||
// RegisterCritical registers a handler that will close the loop if it returns an error.
|
// RegisterCritical registers a handler that will close the loop if it returns an error.
|
||||||
// Warning: If a bad handler is passed in the program will panic.
|
// Warning: If a bad handler is passed in the program will panic.
|
||||||
func (l *Loop) RegisterCritical(h any) {
|
func (l *Loop) RegisterCritical(hs ...any) {
|
||||||
|
for _, h := range hs {
|
||||||
eventType, hv := ValidateHandler(h)
|
eventType, hv := ValidateHandler(h)
|
||||||
l.HandlerFunctions[eventType] = append(l.HandlerFunctions[eventType], hv)
|
l.HandlerFunctions[eventType] = append(l.HandlerFunctions[eventType], hv)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FireFound triggers all handlers registered for the specified event type and returns if handlers were found or an error occurred.
|
// FireFound triggers all handlers registered for the specified event type and returns if handlers were found or an error occurred.
|
||||||
func (l *Loop) FireFound(event any) (found bool, err error) {
|
func (l *Loop) FireFound(event any) (found bool, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user