events

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDispatched

func AssertDispatched(t *testing.T, event Event)

AssertDispatched asserts an event has been dispatched.

func Dispatch

func Dispatch(event Event) error

Dispatch dispatches an event

func Fake

func Fake()

Fake sets up the "test mode" of the events package. Typically you'd call this function in the TestMain function in the package you're testing. It will prevent any events from being fired, instead they will be recorded and be available for assertions.

func InitEvents

func InitEvents() (err error)

InitEvents sets up everything needed to work with events

func RegisterListener

func RegisterListener(name string, listener Listener)

RegisterListener is used to register a listener when a specific event happens

func TestListener added in v0.18.0

func TestListener(t *testing.T, event Event, listener Listener)

TestListener takes an event and a listener and calls the listener's Handle method.

Types

type Event

type Event interface {
	Name() string
}

Event represents the event interface used by all events

type Listener

type Listener interface {
	Handle(msg *message.Message) error
	Name() string
}

Listener represents something that listens to events

Jump to

Keyboard shortcuts

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