Documentation
¶
Overview ¶
Package eventmgr assists with the subscription to, broadcast, and mutation of events. Primarily designed for use with github.com/DanielOaks/girc-go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶
EventHandler holds the priority and handler function of an event.
type EventManager ¶
EventManager lets you attach to and dispatch events.
func (*EventManager) Attach ¶
func (manager *EventManager) Attach(event string, handler HandlerFn, priority int)
Attach lets you attach a handler to the given event.
func (*EventManager) Dispatch ¶
func (manager *EventManager) Dispatch(event string, info map[string]interface{})
Dispatch dispatches the given event/info to all the matching event handlers.
type HandlerFn ¶
HandlerFn defines a function we can call as a handler.
type Handlers ¶
type Handlers struct {
Handlers []EventHandler
}
Handlers holds a list of EventHandlers, including keeping them sorted.
func (Handlers) Attach ¶
func (handlers Handlers) Attach(eventhandler EventHandler) Handlers
Attach attaches a handler to our internal list and returns a new Handlers.
This isn't optimised as much as we probably could. I think most event handlers will attach everything at startup, so it's not a massive issue, though it is something to look at.
func (Handlers) Dispatch ¶
Dispatch dispatches an event to all of our handlers.
func (Handlers) Less ¶
Less returns whether i is less than j.