event

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Type() Type
}

Event represents an event data

type Handler

type Handler interface {
	Handle(Event) (swallowed bool)
}

Handler handles event

type HandlerFunc

type HandlerFunc func(Event) (swallowed bool)

HandlerFunc wraps a function as Handler

func (HandlerFunc) Handle added in v0.0.18

func (fn HandlerFunc) Handle(e Event) bool

Handle implements Handler HandleEvent method

type Registry added in v0.0.18

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

Registry manages event handlers

func NewRegistry added in v0.0.18

func NewRegistry() *Registry

NewRegistry creates an event registry

func (*Registry) Handle added in v0.0.18

func (r *Registry) Handle(t Type, h Handler)

Handle registers event handler by type

func (*Registry) HandleFunc added in v0.0.18

func (r *Registry) HandleFunc(t Type, h HandlerFunc)

HandleFunc registers event handler func by type

func (*Registry) Post added in v0.0.18

func (r *Registry) Post(e Event)

Post posts event to handlers by type

type Type

type Type int64

Type represents type of event

Jump to

Keyboard shortcuts

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