Documentation ¶
Overview ¶
Package event contains types to deal with firing and handling events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEventHandlerOneShot ¶
func AddEventHandlerOneShot(e *Event, h HandlerFunc)
AddEventHandlerOneShot registers event handler h with e. When e fires an event, h is removed from e immediately.
func ExecuteDeferred ¶
func ExecuteDeferred()
ExecuteDeferred processes the queue of deferred actions and executes them. This should only be called by UI. Additionally, it can be called in unit tests to process events programmatically.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event encapsulates an arbitrary event that event handlers may be interested in.
func (*Event) AddHandler ¶
func (e *Event) AddHandler(h HandlerFunc) RemoveHandlerFunc
AddHandler registers event handler h with e. It returns a function to remove h from e if desired.
func (*Event) Fire ¶
func (e *Event) Fire(args interface{})
Fire fires an event to all registered handlers. Arbitrary event arguments may be passed which are in turn passed on to event handlers.
Events are not fired directly, but are put into a deferred queue. This queue is then processed by the UI.
type HandlerFunc ¶
type HandlerFunc func(args interface{})
A HandlerFunc is a function that receives and handles an event. When firing an event using Event.Fire, arbitrary event arguments may be passed that are in turn passed on to the handler function.
type RemoveHandlerFunc ¶
type RemoveHandlerFunc func()
RemoveHandlerFunc is a function that removes a handler from an event.