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
Click to show internal directories.
Click to hide internal directories.