event

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type    EventType
	Payload any
}

nolint:revive Event data structure representing any event we may want to react to

type EventListener added in v1.2.0

type EventListener struct {
	ID int
	// contains filtered or unexported fields
}

nolint:revive EventListener represents a single listener for an event channel

type EventManager added in v1.2.0

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

nolint:revive EventManager implements the event.Manager interface

func NewEventManager added in v1.2.0

func NewEventManager() *EventManager

NewEventManager returns a new instance of EventManager

func (*EventManager) RegisterListener added in v1.2.0

func (m *EventManager) RegisterListener(eventType EventType, listener chan Event) int

RegisterListener registers a listener with the event manager

func (*EventManager) RemoveListener added in v1.2.0

func (m *EventManager) RemoveListener(id int) int

RemoveListener removes a listener from the event manager

func (*EventManager) ReportError added in v1.2.0

func (m *EventManager) ReportError(err error)

ReportError reports an error to all listeners for that event

func (*EventManager) ReportFatalError added in v1.2.0

func (m *EventManager) ReportFatalError(err error)

ReportFatalError reports a fatal error to all listeners for that event

func (*EventManager) Send added in v1.2.0

func (m *EventManager) Send(evt Event)

Send sends an event to all listeners for that event

type EventType

type EventType string

nolint:revive EventType represents different types of events

const (
	// FatalErrorEventType represents a fatal error
	FatalErrorEventType EventType = "fatal-error"
	// ErrorEventType represents a regular error
	ErrorEventType EventType = "error"
)

type Manager added in v1.2.0

type Manager interface {
	RegisterListener(eventType EventType, listener chan Event) int
	RemoveListener(id int) int
	Send(event Event)
	ReportFatalError(err error)
	ReportError(err error)
}

Manager is an interface for managing app wide events

Jump to

Keyboard shortcuts

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