Documentation
¶
Index ¶
- func AddInitiator(kind Kind)
- type Event
- type EventFunc
- type Filter
- func AndFilters[T any](list ...Filter[T]) Filter[T]
- func ExcludeKind[T any](kind Kind) Filter[T]
- func MatchAllKinds[T any](list ...Kind) Filter[T]
- func MatchAny[T any]() Filter[T]
- func MatchAnyKinds[T any](list ...Kind) Filter[T]
- func MatchKind[T any](kind Kind) Filter[T]
- func MatchOnlyKinds[T any](list ...Kind) Filter[T]
- func OrFilters[T any](list ...Filter[T]) Filter[T]
- type Kind
- type Kinds
- func (a Kinds) Has(item Kind) bool
- func (a Kinds) HasAll(list ...Kind) bool
- func (a Kinds) HasAny(list ...Kind) bool
- func (a Kinds) HasOnly(list ...Kind) bool
- func (a Kinds) Not(item Kind) bool
- func (a Kinds) Pick(list ...Kind) Kinds
- func (a Kinds) PickInitiatorKinds() Kinds
- func (a Kinds) String() string
- func (a Kinds) With(list ...Kind) Kinds
- type Mutator
- type MutatorFunc
- type Provider
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddInitiator ¶
func AddInitiator(kind Kind)
AddInitiator registers a new Kind as an initiator kind. Initiator kinds are used to identify the source or trigger type of an operation (e.g. UI, System).
Types ¶
type Event ¶
type Event[T any] = Registry[EventFunc[T], T]
Event defines a registry of event hooks for type T. Event hooks are used to observe or react to lifecycle events without modifying data.
type EventFunc ¶
EventFunc represents a non-mutating hook function for a value of type T. It can be used for logging, auditing, notifications, or other side effects.
type Filter ¶
Filter defines a predicate used to determine whether a hook should apply based on the current context, hook kinds, and target value.
func AndFilters ¶
AndFilters combines multiple filters using logical AND. Returns true only if all filters return true.
func ExcludeKind ¶
ExcludeKind returns a filter that matches only if the given kind is NOT present.
func MatchAllKinds ¶
MatchAllKinds returns a filter that matches only if all specified kinds are present.
func MatchAnyKinds ¶
MatchAnyKinds returns a filter that matches if at least one of the specified kinds is present.
func MatchOnlyKinds ¶
MatchOnlyKinds returns a filter that matches only if the kinds exactly match the provided list.
type Kind ¶
type Kind string
Kind represents a type or phase of a hookable event.
const ( KindBefore Kind = "Before" KindAfter Kind = "After" KindFind Kind = "Find" KindCreate Kind = "Create" KindUpdate Kind = "Update" KindDelete Kind = "Delete" KindLock Kind = "Lock" KindOne Kind = "One" KindMany Kind = "Many" KindByID Kind = "ByID" KindUI Kind = "UI" KindSystem Kind = "System" KindSilent Kind = "Silent" )
Base hook kinds commonly used across modules.
type Kinds ¶
Kinds is a set of Kind values used to define which events a hook applies to.
func (Kinds) HasOnly ¶
HasOnly checks if the set contains only the specified kinds (no more, no less).
func (Kinds) Pick ¶
Pick returns a new Kinds set containing only the kinds from the input list that are present in the original set.
func (Kinds) PickInitiatorKinds ¶
PickInitiatorKinds returns a new Kinds set containing only the kinds from the current set that match known initiator kinds (e.g., UI, System, Silent).
type Mutator ¶
type Mutator[T any] = Registry[MutatorFunc[T], T]
Mutator defines a registry of mutation hooks for type T. Mutators can transform a value before or after a specific action.
type MutatorFunc ¶
MutatorFunc represents a hook function that can modify a value of type T before it proceeds through the system. It receives context and hook kinds.
type Provider ¶
type Provider[H any, V any] interface { // Find returns a sequence of handlers matching the given context, kinds, and value. Find(c context.Context, kinds Kinds, value V) iter.Seq[H] }
Provider defines an interface for retrieving applicable hook handlers based on the current context, kinds, and value.
type Registry ¶
type Registry[H any, V any] interface { // Add registers a new hook handler with an associated filter. Add(filter Filter[V], hook H) Registry[H, V] }
Registry defines a hook registry that allows adding hook handlers with filters. The registry may contain multiple handlers that match different kinds or values.