events

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher is used to dispatch events to listeners

func NewDispatcher

func NewDispatcher(log *zap.Logger) *Dispatcher

NewDispatcher returns a new dispatcher instance

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(event Event)

Dispatch given event

func (*Dispatcher) Register

func (d *Dispatcher) Register(listener ...EventListener)

Register events listeners

type Event

type Event interface {
	Name() EventName
}

Event is a event that can be dispatched and 0 .. n listeners may listen for

type EventListener

type EventListener interface {
	ForEvent() EventName
	Handle(ev Event) error
}

EventListener enables to listen for a certain event

type EventName

type EventName string

EventName is the unique name of the event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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