MCPcopy
hub / github.com/pocketbase/pocketbase / Bind

Method Bind

tools/hook/tagged.go:58–70  ·  view source on GitHub ↗

Bind registers the provided handler to the current hooks queue. It is similar to [Hook.Bind] with the difference that the handler function is invoked only if the event data tags satisfy h.CanTriggerOn.

(handler *Handler[T])

Source from the content-addressed store, hash-verified

56// It is similar to [Hook.Bind] with the difference that the handler
57// function is invoked only if the event data tags satisfy h.CanTriggerOn.
58func (h *TaggedHook[T]) Bind(handler *Handler[T]) string {
59 fn := handler.Func
60
61 handler.Func = func(e T) error {
62 if h.CanTriggerOn(e.Tags()) {
63 return fn(e)
64 }
65
66 return e.Next()
67 }
68
69 return h.mainHook.Bind(handler)
70}
71
72// BindFunc registers a new handler with the specified function.
73//

Callers

nothing calls this directly

Calls 4

CanTriggerOnMethod · 0.95
TagsMethod · 0.65
NextMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected