Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is an event that can be triggered exactly once. Consumers that register themselves after the event was triggered, will be called immediately.
func (*Event) OnTrigger ¶
func (e *Event) OnTrigger(callback func()) (unsubscribe func())
OnTrigger registers a callback that will be called when the event is triggered. If the event was already triggered, the callback will be called immediately.
func (*Event) Trigger ¶
Trigger triggers the event. If the event was already triggered, this method does nothing.
func (*Event) WasTriggered ¶
WasTriggered returns true if the event was already triggered.
type Event1 ¶
type Event1[T any] struct { // contains filtered or unexported fields }
Event1 is an event with a single parameter that can be triggered exactly once. Consumers that register themselves after the event was triggered, will be called immediately.
func (*Event1[T]) OnTrigger ¶
func (e *Event1[T]) OnTrigger(callback func(T)) (unsubscribe func())
OnTrigger registers a callback that will be called when the event is triggered. If the event was already triggered, the callback will be called immediately.
func (*Event1[T]) Trigger ¶
Trigger triggers the event. If the event was already triggered, this method does nothing.
func (*Event1[T]) WasTriggered ¶
WasTriggered returns true if the event was already triggered.