event

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(IEvent) error // Event handler type

type HandlerID

type HandlerID uuid.UUID // Event handler ID

func (HandlerID) String

func (hid HandlerID) String() string

type HandlerIDList

type HandlerIDList []HandlerID

func (HandlerIDList) Cmp

func (list HandlerIDList) Cmp(i int, id HandlerID) int

func (HandlerIDList) Len

func (list HandlerIDList) Len() int

func (HandlerIDList) Less

func (list HandlerIDList) Less(i, j int) bool

func (HandlerIDList) Swap

func (list HandlerIDList) Swap(i, j int)

type IEvent

type IEvent interface {
	Type() Type
	String() string

} // Event interface

type IListener

type IListener interface {
	// Register registers an event handler
	Register(Type, Handler) HandlerID
	// Unregister deletes the event handler with the specified ID
	Unregister(HandlerID) error
	// Fire starts event processing
	Fire(IEvent) error
}

IListener Event Listener Interface

The implementation of asynchronous event processing is assigned to the author of the event handler. For example, a handler can simply send an event to a channel that is being listened to by one or more goroutines performing valid event processing.

type Listener

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

func New

func New() *Listener

New creates new event listener

func (*Listener) Fire

func (l *Listener) Fire(ev IEvent) error

func (*Listener) Register

func (l *Listener) Register(t Type, h Handler) HandlerID

func (*Listener) Unregister

func (l *Listener) Unregister(id HandlerID) error

type Type

type Type string // Event type

Jump to

Keyboard shortcuts

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