Documentation ¶
Overview ¶
Package event is a concurrency-safe event dispatcher plugin for squircy3.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher binds functions to be called indirectly by unrelated code.
func FromPlugins ¶
func FromPlugins(m *plugin.Manager) (*Dispatcher, error)
FromPlugins returns the event plugin's Dispatcher or an error if it fails.
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
NewDispatcher returns an event dispatcher, ready for use.
func NewDispatcherLimit ¶
func NewDispatcherLimit(limit int) *Dispatcher
NewDispatcherLimit returns an event dispatcher with a buffer size of limit.
func (*Dispatcher) Bind ¶
func (d *Dispatcher) Bind(name string, handler Handler)
Bind adds the given handler to the list of handlers for the event.
func (*Dispatcher) Emit ¶
func (d *Dispatcher) Emit(name string, data map[string]interface{})
Emit will call bound handlers for the given in event.
This method does not block unless the underlying channel becomes full. The map received by this method is not copied; avoid writing to it once it has been passed into this method.
func (*Dispatcher) Loop ¶
func (d *Dispatcher) Loop()
Loop emits events in an infinite loop until the dispatcher is stopped.
If the Dispatcher is not running when Loop is called, it will be started. This method should be called in a separate goroutine. More than one worker can be started by calling this method multiple times in separate goroutines.
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop signals to the dispatcher to stop emitting events.
All workers started with Loop will stop processing without draining the pending events.
func (*Dispatcher) Unbind ¶
func (d *Dispatcher) Unbind(name string, handler Handler)
Unbind removes the given handler from the list of handlers for the event.
type Event ¶
type Event struct { Name string Data map[string]interface{} // contains filtered or unexported fields }
An Event is used to pass data between an emitter and handler.
func (*Event) StopPropagation ¶
func (e *Event) StopPropagation()
StopPropagation will stop any further handlers being fired for this event.