event

package
v0.0.0-...-c635e59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 77

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateGroupConstructor

func CreateGroupConstructor[GroupType any, GroupPtrType ptrGroupType[GroupType, GroupPtrType]](newFunc func() GroupPtrType) func(...GroupPtrType) GroupPtrType

CreateGroupConstructor returns the linkable constructor for the given event group.

func IsInterfaceNil

func IsInterfaceNil(param interface{}) bool

Types

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is an event with no generic parameters.

func New

func New(opts ...Option) *Event

New creates a new event with no generic parameters.

func (Event) Hook

func (e Event) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event) LinkTo

func (e *Event) LinkTo(target *Event)

LinkTo links the event to the given target event (nil unlinks).

func (*Event) Trigger

func (e *Event) Trigger()

Trigger invokes the hooked callbacks.

type Event1

type Event1[T1 any] struct {
	// contains filtered or unexported fields
}

Event1 is an event with 1 generic parameters.

func New1

func New1[T1 any](opts ...Option) *Event1[T1]

New1 creates a new event with 1 generic parameters.

func (Event1) Hook

func (e Event1) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event1[T1]) LinkTo

func (e *Event1[T1]) LinkTo(target *Event1[T1])

LinkTo links the event to the given target event (nil unlinks).

func (*Event1[T1]) Trigger

func (e *Event1[T1]) Trigger(arg1 T1)

Trigger invokes the hooked callbacks with the given parameters.

type Event2

type Event2[T1, T2 any] struct {
	// contains filtered or unexported fields
}

Event2 is an event with 2 generic parameters.

func New2

func New2[T1, T2 any](opts ...Option) *Event2[T1, T2]

New2 creates a new event with 2 generic parameters.

func (Event2) Hook

func (e Event2) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event2[T1, T2]) LinkTo

func (e *Event2[T1, T2]) LinkTo(target *Event2[T1, T2])

LinkTo links the event to the given target event (nil unlinks).

func (*Event2[T1, T2]) Trigger

func (e *Event2[T1, T2]) Trigger(arg1 T1, arg2 T2)

Trigger invokes the hooked callbacks with the given parameters.

type Event3

type Event3[T1, T2, T3 any] struct {
	// contains filtered or unexported fields
}

Event3 is an event with 3 generic parameters.

func New3

func New3[T1, T2, T3 any](opts ...Option) *Event3[T1, T2, T3]

New3 creates a new event with 3 generic parameters.

func (Event3) Hook

func (e Event3) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event3[T1, T2, T3]) LinkTo

func (e *Event3[T1, T2, T3]) LinkTo(target *Event3[T1, T2, T3])

LinkTo links the event to the given target event (nil unlinks).

func (*Event3[T1, T2, T3]) Trigger

func (e *Event3[T1, T2, T3]) Trigger(arg1 T1, arg2 T2, arg3 T3)

Trigger invokes the hooked callbacks with the given parameters.

type Event4

type Event4[T1, T2, T3, T4 any] struct {
	// contains filtered or unexported fields
}

Event4 is an event with 4 generic parameters.

func New4

func New4[T1, T2, T3, T4 any](opts ...Option) *Event4[T1, T2, T3, T4]

New4 creates a new event with 4 generic parameters.

func (Event4) Hook

func (e Event4) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event4[T1, T2, T3, T4]) LinkTo

func (e *Event4[T1, T2, T3, T4]) LinkTo(target *Event4[T1, T2, T3, T4])

LinkTo links the event to the given target event (nil unlinks).

func (*Event4[T1, T2, T3, T4]) Trigger

func (e *Event4[T1, T2, T3, T4]) Trigger(arg1 T1, arg2 T2, arg3 T3, arg4 T4)

Trigger invokes the hooked callbacks with the given parameters.

type Event5

type Event5[T1, T2, T3, T4, T5 any] struct {
	// contains filtered or unexported fields
}

Event5 is an event with 5 generic parameters.

func New5

func New5[T1, T2, T3, T4, T5 any](opts ...Option) *Event5[T1, T2, T3, T4, T5]

New5 creates a new event with 5 generic parameters.

func (Event5) Hook

func (e Event5) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event5[T1, T2, T3, T4, T5]) LinkTo

func (e *Event5[T1, T2, T3, T4, T5]) LinkTo(target *Event5[T1, T2, T3, T4, T5])

LinkTo links the event to the given target event (nil unlinks).

func (*Event5[T1, T2, T3, T4, T5]) Trigger

func (e *Event5[T1, T2, T3, T4, T5]) Trigger(arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5)

Trigger invokes the hooked callbacks with the given parameters.

type Event6

type Event6[T1, T2, T3, T4, T5, T6 any] struct {
	// contains filtered or unexported fields
}

Event6 is an event with 6 generic parameters.

func New6

func New6[T1, T2, T3, T4, T5, T6 any](opts ...Option) *Event6[T1, T2, T3, T4, T5, T6]

New6 creates a new event with 6 generic parameters.

func (Event6) Hook

func (e Event6) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event6[T1, T2, T3, T4, T5, T6]) LinkTo

func (e *Event6[T1, T2, T3, T4, T5, T6]) LinkTo(target *Event6[T1, T2, T3, T4, T5, T6])

LinkTo links the event to the given target event (nil unlinks).

func (*Event6[T1, T2, T3, T4, T5, T6]) Trigger

func (e *Event6[T1, T2, T3, T4, T5, T6]) Trigger(arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5, arg6 T6)

Trigger invokes the hooked callbacks with the given parameters.

type Event7

type Event7[T1, T2, T3, T4, T5, T6, T7 any] struct {
	// contains filtered or unexported fields
}

Event7 is an event with 7 generic parameters.

func New7

func New7[T1, T2, T3, T4, T5, T6, T7 any](opts ...Option) *Event7[T1, T2, T3, T4, T5, T6, T7]

New7 creates a new event with 7 generic parameters.

func (Event7) Hook

func (e Event7) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event7[T1, T2, T3, T4, T5, T6, T7]) LinkTo

func (e *Event7[T1, T2, T3, T4, T5, T6, T7]) LinkTo(target *Event7[T1, T2, T3, T4, T5, T6, T7])

LinkTo links the event to the given target event (nil unlinks).

func (*Event7[T1, T2, T3, T4, T5, T6, T7]) Trigger

func (e *Event7[T1, T2, T3, T4, T5, T6, T7]) Trigger(arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5, arg6 T6, arg7 T7)

Trigger invokes the hooked callbacks with the given parameters.

type Event8

type Event8[T1, T2, T3, T4, T5, T6, T7, T8 any] struct {
	// contains filtered or unexported fields
}

Event8 is an event with 8 generic parameters.

func New8

func New8[T1, T2, T3, T4, T5, T6, T7, T8 any](opts ...Option) *Event8[T1, T2, T3, T4, T5, T6, T7, T8]

New8 creates a new event with 8 generic parameters.

func (Event8) Hook

func (e Event8) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event8[T1, T2, T3, T4, T5, T6, T7, T8]) LinkTo

func (e *Event8[T1, T2, T3, T4, T5, T6, T7, T8]) LinkTo(target *Event8[T1, T2, T3, T4, T5, T6, T7, T8])

LinkTo links the event to the given target event (nil unlinks).

func (*Event8[T1, T2, T3, T4, T5, T6, T7, T8]) Trigger

func (e *Event8[T1, T2, T3, T4, T5, T6, T7, T8]) Trigger(arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5, arg6 T6, arg7 T7, arg8 T8)

Trigger invokes the hooked callbacks with the given parameters.

type Event9

type Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any] struct {
	// contains filtered or unexported fields
}

Event9 is an event with 9 generic parameters.

func New9

func New9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](opts ...Option) *Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9]

New9 creates a new event with 9 generic parameters.

func (Event9) Hook

func (e Event9) Hook(triggerFunc TriggerFunc, opts ...Option) *Hook[TriggerFunc]

Hook adds a new callback to the event and returns the corresponding Hook.

func (*Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) LinkTo

func (e *Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) LinkTo(target *Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9])

LinkTo links the event to the given target event (nil unlinks).

func (*Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) Trigger

func (e *Event9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) Trigger(arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5, arg6 T6, arg7 T7, arg8 T8, arg9 T9)

Trigger invokes the hooked callbacks with the given parameters.

type Group

type Group[GroupType any, GroupPtrType ptrGroupType[GroupType, GroupPtrType]] struct {
	sync.Once
	// contains filtered or unexported fields
}

Group is a trait that can be embedded into a struct to make the contained events linkable.

func (*Group[GroupType, GroupPtrType]) LinkTo

func (g *Group[GroupType, GroupPtrType]) LinkTo(target GroupPtrType)

LinkTo links the group to another group of the same type (nil unlinks).

type Hook

type Hook[TriggerFunc any] struct {
	// contains filtered or unexported fields
}

Hook is a container that holds a trigger function and its trigger settings.

func (Hook) MaxTriggerCount

func (t Hook) MaxTriggerCount() int

MaxTriggerCount returns the maximum number of times Trigger can be called.

func (Hook) MaxTriggerCountReached

func (t Hook) MaxTriggerCountReached() bool

MaxTriggerCountReached returns true if the maximum number of times Trigger can be called was reached.

func (Hook) TriggerCount

func (t Hook) TriggerCount() int

TriggerCount returns the number of times Trigger was called.

func (*Hook[TriggerFunc]) Unhook

func (h *Hook[TriggerFunc]) Unhook()

Unhook removes the callback from the event.

func (Hook) WasTriggered

func (t Hook) WasTriggered() bool

WasTriggered returns true if Trigger was called at least once.

func (*Hook[TriggerFunc]) WorkerPool

func (h *Hook[TriggerFunc]) WorkerPool() *workerpool.WorkerPool

WorkerPool returns the worker pool that is used to trigger the callback.

type Option

type Option = options.Option[triggerSettings]

Option is a function that configures the triggerSettings.

func WithMaxTriggerCount

func WithMaxTriggerCount(maxTriggerCount uint64) Option

WithMaxTriggerCount sets the maximum number of times an entity shall be triggered.

func WithPreTriggerFunc

func WithPreTriggerFunc(preTriggerFunc any) Option

WithPreTriggerFunc sets a function that is synchronously called before the trigger is executed.

func WithWorkerPool

func WithWorkerPool(workerPool *workerpool.WorkerPool) Option

WithWorkerPool sets the worker pool that is used to process the trigger (nil forces execution in-place).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL