event

package
v0.4.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package event implements an embeddable type that uses the observation pattern to facilitate an event bus.

Index

Constants

View Source
const (
	// Shutdown is the shutdown event.
	Shutdown = Type(iota)
	// Reboot is the reboot event.
	Reboot
	// Upgrade is the upgrade event.
	Upgrade
)

Variables

This section is empty.

Functions

func Bus

func Bus() *singleton

Bus represents an event bus.

nolint: golint

Types

type Channel

type Channel chan Event

Channel is a channel for sending events.

type Embeddable

type Embeddable struct {
	Chan Channel
	// contains filtered or unexported fields
}

Embeddable is a type that implements sane defaults as an observer.

func (*Embeddable) Channel

func (e *Embeddable) Channel() Channel

Channel implements the Observer interface.

func (*Embeddable) Types

func (e *Embeddable) Types() []Type

Types implements the Observer interface.

type Event

type Event struct {
	Type Type
	Data interface{}
}

Event represents an event in the observer pattern.

type Listeners

type Listeners []Channel

Listeners is a slice of listeners to send events to.

type Notifier

type Notifier interface {
	Notify(Event)
	Register(Observer, ...Type)
	Unregister(Observer)
}

Notifier is a component of the observer design pattern.

type ObserveNotifier

type ObserveNotifier interface {
	Observer
	Notifier
}

ObserveNotifier is a composite interface consisting of the Observer, and Notifier interfaces.

type Observer

type Observer interface {
	Channel() Channel
	Types() []Type
}

Observer is a component of the observer design pattern.

type Type

type Type int

Type is event type.

Jump to

Keyboard shortcuts

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