events

package
v0.0.0-...-dac7c1c Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorHandlerAlreadyRegistered = 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) ClearHandlers

func (ed *EventDispatcher) ClearHandlers()

func (*EventDispatcher) DispatchEvent

func (ed *EventDispatcher) DispatchEvent(event EventInterface) error

func (*EventDispatcher) HasHandler

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

func (*EventDispatcher) RegisterHandler

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

func (*EventDispatcher) RemoveHandler

func (ed *EventDispatcher) RemoveHandler(event EventInterface, handler EventHandlerInterface) error

type EventDispatcherInterface

type EventDispatcherInterface interface {
	RegisterHandler(eventName string, handler EventHandlerInterface) error
	DispatchEvent(event EventInterface) error
	RemoveHandler(event EventInterface, handler EventHandlerInterface) error
	HasHandler(eventName string, handler EventHandlerInterface) bool
	ClearHandlers()
}

type EventHandlerInterface

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

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