event

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher added in v0.1.0

type Dispatcher[T comparable] interface {
	// AddEventListener registers a Listener and returns the listener ID
	AddEventListener(listener Listener[T]) (id int)
	// HasEventListener reports whether the Dispatcher has specified listener
	HasEventListener(id int) bool
	// RemoveEventListener removes specified listener
	RemoveEventListener(id int) bool
	// DispatchEvent dispatchs event
	DispatchEvent(event Event[T]) bool
}

Dispatcher represents an event dispatcher

type Event

type Event[T comparable] interface {
	Type() T // Type gets type of event
}

Event is the interface that wraps the basic Type method.

type Listener added in v0.1.0

type Listener[T comparable] interface {
	EventType() T    // EventType gets type of listening event
	Handle(Event[T]) // Handle handles fired event
}

A Listener handles fired event

func Listen added in v0.1.0

func Listen[T comparable, E Event[T]](eventType T, handler func(E)) Listener[T]

Listen creates a Listener by eventType and handler function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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