mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-12 09:17:27 +02:00
[#109] prealocated handlers and replaced OnRecordBeforeDeleteRequest with OnModelBeforeDelete
This commit is contained in:
1 parent
d8c8289269
commit
c4fcba5210
2 files changed
+18
-14
No files matched your search
+3
-1
@@ -44,7 +44,9 @@ func (h *Hook[T]) Reset() {
|
||||
// - any non-nil error is returned in one of the handlers
|
||||
func (h *Hook[T]) Trigger(data T, oneOffHandlers ...Handler[T]) error {
|
||||
h.mux.Lock()
|
||||
handlers := append(h.handlers, oneOffHandlers...) //nolint:gocritic
|
||||
handlers := make([]Handler[T], 0, len(h.handlers)+len(oneOffHandlers))
|
||||
handlers = append(handlers, h.handlers...)
|
||||
handlers = append(handlers, oneOffHandlers...)
|
||||
// unlock is not deferred to avoid deadlocks when Trigger is called recursive by the handlers
|
||||
h.mux.Unlock()
|
||||
|
||||
|
||||
Reference in new issue
Block a user