events

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: AGPL-3.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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