Documentation ¶
Index ¶
- Variables
- func Attach[T any](event *Linkable[T], callback func(event T), triggerMaxCount ...uint64) (detachFunc func())
- func AttachWithWorkerPool[T any](event *Linkable[T], callback func(event T), wp *workerpool.UnboundedWorkerPool, ...) (detachFunc func())
- func Hook[T any](event *Linkable[T], callback func(event T), triggerMaxCount ...uint64) (detachFunc func())
- func LinkableConstructor[A any, B ptrLinkableCollectionType[A, B]](newFunc func() B) (constructor func(...B) B)
- type Closure
- type Event
- func (e *Event[T]) Attach(closure *Closure[T], triggerMaxCount ...uint64)
- func (e *Event[T]) AttachWithWorkerPool(closure *Closure[T], wp *workerpool.UnboundedWorkerPool, ...)
- func (e *Event[T]) Detach(closure *Closure[T])
- func (e *Event[T]) DetachAll()
- func (e *Event[T]) Hook(closure *Closure[T], triggerMaxCount ...uint64)
- func (e *Event[T]) HookAfter(closure *Closure[T], triggerMaxCount ...uint64)
- func (e *Event[T]) HookBefore(closure *Closure[T], triggerMaxCount ...uint64)
- func (e *Event[T]) Trigger(event T)
- type Linkable
- type LinkableCollection
Constants ¶
This section is empty.
Variables ¶
var Loop *workerpool.UnboundedWorkerPool
Functions ¶
func AttachWithWorkerPool ¶
func AttachWithWorkerPool[T any](event *Linkable[T], callback func(event T), wp *workerpool.UnboundedWorkerPool, triggerMaxCount ...uint64) (detachFunc func())
func LinkableConstructor ¶
func LinkableConstructor[A any, B ptrLinkableCollectionType[A, B]](newFunc func() B) (constructor func(...B) B)
LinkableConstructor returns the linkable constructor for the given type.
Types ¶
type Closure ¶
Closure represents function reference uniquely.
func NewClosure ¶
NewClosure creates a new Closure.
type Event ¶
type Event[T any] struct { // contains filtered or unexported fields }
Event represents an object that is triggered to notify code of "interesting updates" that may affect its behavior.
func (*Event[T]) Attach ¶
Attach allows to register a Closure that is executed asynchronously when the Event triggers. If 'triggerMaxCount' is >0, the Closure is automatically detached after exceeding the trigger limit.
func (*Event[T]) AttachWithWorkerPool ¶
func (e *Event[T]) AttachWithWorkerPool(closure *Closure[T], wp *workerpool.UnboundedWorkerPool, triggerMaxCount ...uint64)
AttachWithWorkerPool allows to register a Closure that is executed asynchronously in the specified worker pool when the Event triggers. If 'triggerMaxCount' is >0, the Closure is automatically detached after exceeding the trigger limit.
func (*Event[T]) DetachAll ¶
func (e *Event[T]) DetachAll()
DetachAll removes all registered callbacks.
func (*Event[T]) Hook ¶
Hook allows to register a Closure that is executed when the Event triggers. If 'triggerMaxCount' is >0, the Closure is automatically detached after exceeding the trigger limit.
func (*Event[T]) HookAfter ¶
HookAfter allows to register a Closure that is executed after the Event triggered. If 'triggerMaxCount' is >0, the Closure is automatically detached after exceeding the trigger limit.
func (*Event[T]) HookBefore ¶
HookBefore allows to register a Closure that is executed before the Event triggers. If 'triggerMaxCount' is >0, the Closure is automatically detached after exceeding the trigger limit.
type Linkable ¶
Linkable represents a special kind of Event that is part of a LinkableCollection of events.
func NewLinkable ¶
NewLinkable creates a new Linkable.
type LinkableCollection ¶
type LinkableCollection[A any, B ptrLinkableCollectionType[A, B]] struct { sync.Once // contains filtered or unexported fields }
LinkableCollection can be embedded into collections of linkable Events to make the entire collection linkable.
func (*LinkableCollection[A, B]) LinkTo ¶
func (l *LinkableCollection[A, B]) LinkTo(optLinkTargets ...B)
LinkTo offers a way to link the collection to another collection of the same type.