event

package
v0.0.0-...-ad944e5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Dispatcher is a very, very basic event dispatcher. It keeps a map between event types, and functions to call when an event is dispatched. There are no background processes involved.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates a new Dispatcher instance.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(eventType Type)

Dispatch emits an event via this Dispatcher instance, calling any listener functions associated with the given event Type. This method is safe for concurrent use.

func (*Dispatcher) RegisterListener

func (d *Dispatcher) RegisterListener(eventType Type, lfn func())

RegisterListener is used to register an event listener. An event listener is basically just a function that will be called when a given event Type is dispatched. This method is safe for concurrent use.

type Type

type Type int

Type represents enumerations of event types.

const (
	// TypeStartup is sent when Barbara is first started.
	TypeStartup Type = iota
	// TypeShutdown is sent when Barbara is completely shutting down.
	TypeShutdown
	// TypeWM is an event that comes from a window manager.
	TypeWM
)

Jump to

Keyboard shortcuts

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