events

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

type Emitter interface {
	// Emit fires an event with the given name and payload.
	Emit(EventName, interface{})
	// On registers a listener for the given event name.
	On(EventName, ...Listener)
	// OnMany registers a listener for the given event names.
	ListenEvents(Listener, ...EventName)
}

Emitter is an interface that allows to fire events.

func NewEmitter

func NewEmitter(log Logger) Emitter

NewEmitter creates a new Emitter.

type EventName

type EventName string

EventName is a string alias for event names.

type Listener

type Listener func(EventName, interface{}) error

Listener is a function that is called when an event is fired.

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Logger is an interface that allows to log events.

Jump to

Keyboard shortcuts

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