event

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 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 Bus

type Bus interface {
	// AddListener allows a listener to listen to events
	// dispatched on this Bus.
	AddListener(l Listener)
	// RemoveListener allows a listener to stop listening
	// to events dispatched on this Bus.
	RemoveListener(l Listener)
	// DispatchEvent dispatches an event to all listeners
	// listening to this Bus.
	DispatchEvent(e Event) error
}

Bus is the interface that must be implemented by an event bus.

type Event

type Event interface{}

type Listener

type Listener interface {
	OnEvent(e Event) error
	GetUUID() uuid.UUID
}

type MemoryBus

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

func NewMemoryBus

func NewMemoryBus() *MemoryBus

func (*MemoryBus) AddListener

func (b *MemoryBus) AddListener(l Listener)

func (*MemoryBus) DispatchEvent

func (b *MemoryBus) DispatchEvent(e Event) error

func (*MemoryBus) RemoveListener

func (b *MemoryBus) RemoveListener(l Listener)

type MockBus

type MockBus struct {
	mock.Mock
}

func (*MockBus) AddListener

func (m *MockBus) AddListener(l Listener)

func (*MockBus) DispatchEvent

func (m *MockBus) DispatchEvent(e Event) error

func (*MockBus) RemoveListener

func (m *MockBus) RemoveListener(l Listener)

type MockEvent

type MockEvent struct{}

type MockListener

type MockListener struct {
	mock.Mock
}

func (*MockListener) GetUUID

func (m *MockListener) GetUUID() uuid.UUID

func (*MockListener) OnEvent

func (m *MockListener) OnEvent(e Event) error

type TempListener

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

func NewTempListener

func NewTempListener(onEvent func(e Event) error) TempListener

func (TempListener) GetUUID

func (t TempListener) GetUUID() uuid.UUID

func (TempListener) OnEvent

func (t TempListener) OnEvent(e Event) error

Jump to

Keyboard shortcuts

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