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[T]) ListenerID // HasEventListener reports whether the Dispatcher has specified event handler HasEventListener(ListenerID) bool // RemoveEventListener removes specified event handler RemoveEventListener(ListenerID) bool // DispatchEvent dispatchs event DispatchEvent(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
type ListenerID ¶ added in v0.1.6
type ListenerID = int64
ListenerID represents an event listener ID
Click to show internal directories.
Click to hide internal directories.