event

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface{}

type HandlerFn

type HandlerFn func(e Event)

type Manager

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

Manager is an event manager.

func NewManager

func NewManager() *Manager

func (*Manager) Fire

func (m *Manager) Fire(event Event)

Fire fires an event and returns after all subscribers are complete handling it. Any panic by a subscriber is caught so firing the event to the next subscriber can proceed .

func (*Manager) FireParallel

func (m *Manager) FireParallel(event Event, after ...HandlerFn)

FireParallel fires an event in a new goroutine and returns immediately. It optionally runs handlers after all subscribers are done and passes the potentially modified version of the fired event. If an after handler panics no further handlers in the slice will be run.

func (*Manager) Subscribe

func (m *Manager) Subscribe(eventType Type, priority int, fn HandlerFn) (unsubscribe func())

func (*Manager) Wait

func (m *Manager) Wait()

type Type

type Type reflect.Type

func TypeOf

func TypeOf(e Event) Type

TypeOf is a helper func to make sure the reflect.Type implements the Event interface.

Jump to

Keyboard shortcuts

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