MCPcopy
hub / github.com/pocketbase/pocketbase / BindFunc

Method BindFunc

tools/hook/hook.go:111–113  ·  view source on GitHub ↗

BindFunc is similar to Bind but registers a new handler from just the provided function. The registered handler is added with a default 0 priority and the id will be autogenerated. If you want to register a handler with custom priority or id use the [Hook.Bind] method.

(fn func(e T) error)

Source from the content-addressed store, hash-verified

109//
110// If you want to register a handler with custom priority or id use the [Hook.Bind] method.
111func (h *Hook[T]) BindFunc(fn func(e T) error) string {
112 return h.Bind(&Handler[T]{Func: fn})
113}
114
115// Unbind removes one or many hook handler by their id.
116func (h *Hook[T]) Unbind(idsToRemove ...string) {

Callers 15

TestHookAddHandlerAndAddFunction · 0.45
TestHookLengthFunction · 0.45
TestHookUnbindFunction · 0.45
TestHookUnbindAllFunction · 0.45
TestTaggedHookFunction · 0.45
TestDeleteExpiredOTPsFunction · 0.45

Calls 1

BindMethod · 0.95

Tested by 15

TestHookAddHandlerAndAddFunction · 0.36
TestHookLengthFunction · 0.36
TestHookUnbindFunction · 0.36
TestHookUnbindAllFunction · 0.36
TestTaggedHookFunction · 0.36
TestDeleteExpiredOTPsFunction · 0.36