fix: make RegisterCritical variadic for API consistency with RegisterCriticalUntilLatest

This commit is contained in:
adman
2026-07-30 00:05:39 +02:00
parent 84b28d4c12
commit 9063a0328d
+3 -1
View File
@@ -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.
// 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)
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.
func (l *Loop) FireFound(event any) (found bool, err error) {