event

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	RegisterListener(listener *Listener)
	RemoveListener(listener *Listener)
	RemoveAllListeners()
	BroadcastEvent(ctx context.Context, event Event)
}

func NewBroadcaster

func NewBroadcaster() Broadcaster

type Event

type Event interface {
	EventSource() any

	Time() time.Time
}

type Listener

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

func Listen

func Listen[E Event, F ListenerFunc[E]](handler F) *Listener

func (*Listener) EventType

func (l *Listener) EventType() reflect.Type

func (*Listener) Identifier

func (l *Listener) Identifier() string

func (*Listener) OnEvent

func (l *Listener) OnEvent(ctx context.Context, event Event)

type ListenerFunc

type ListenerFunc[E Event] interface {
	~func(ctx context.Context, event E)
}

type ListenerRegistry

type ListenerRegistry interface {
	RegisterListener(listener *Listener)
	Listeners() []*Listener
}

type Publisher

type Publisher interface {
	PublishEvent(ctx context.Context, event Event)
}

Jump to

Keyboard shortcuts

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