events

package
v0.0.0-...-d9e78da Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHandlerAlreadyRegistered = errors.New("handler already registered")

Functions

This section is empty.

Types

type EventDispatcher

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

func NewEventDispatcher

func NewEventDispatcher() *EventDispatcher

func (*EventDispatcher) Clear

func (ed *EventDispatcher) Clear()

func (*EventDispatcher) Dispatch

func (ev *EventDispatcher) Dispatch(event EventInterface) error

func (*EventDispatcher) Has

func (ed *EventDispatcher) Has(eventName string, handler EventHandlerInterface) bool

func (*EventDispatcher) Register

func (ed *EventDispatcher) Register(eventName string, handler EventHandlerInterface) error

func (*EventDispatcher) Remove

func (ed *EventDispatcher) Remove(eventName string, handler EventHandlerInterface) error

type EventDispatcherInterface

type EventDispatcherInterface interface {
	Register(eventName string, handler EventHandlerInterface) error
	Dispatch(event EventInterface) error
	Remove(eventName string, handler EventHandlerInterface) error
	Has(eventName string, handler EventHandlerInterface) bool
	Clear()
}

type EventHandlerInterface

type EventHandlerInterface interface {
	Handle(event EventInterface, wg *sync.WaitGroup)
}

type EventInterface

type EventInterface interface {
	GetName() string
	GetDateTime() time.Time
	GetPayload() interface{}
	SetPayload(payload interface{})
}

Jump to

Keyboard shortcuts

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