Documentation ¶
Index ¶
- type Dispatcher
- func (d *Dispatcher) Dispatch(evname eventtype.EventType, ev interface{}) int
- func (d *Dispatcher) Initialize()
- func (d *Dispatcher) Subscribe(evname eventtype.EventType, callBack dispatcheri.Callback)
- func (d *Dispatcher) SubscribeID(evname eventtype.EventType, id interface{}, callBack dispatcheri.Callback)
- func (d *Dispatcher) UnsubscribeAllID(id interface{}) int
- func (d *Dispatcher) UnsubscribeID(evname eventtype.EventType, id interface{}) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher implements an event dispatcher.
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
NewDispatcher creates and returns a new event dispatcher.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(evname eventtype.EventType, ev interface{}) int
Dispatch dispatches the specified event to all registered subscribers. The function returns the number of subscribers to which the event was dispatched.
func (*Dispatcher) Initialize ¶
func (d *Dispatcher) Initialize()
Initialize initializes the event dispatcher. It is normally used by other types which embed a dispatcher.
func (*Dispatcher) Subscribe ¶
func (d *Dispatcher) Subscribe(evname eventtype.EventType, callBack dispatcheri.Callback)
Subscribe subscribes a callback to events with the given name. If it is necessary to unsubscribe later, SubscribeID should be used instead.
func (*Dispatcher) SubscribeID ¶
func (d *Dispatcher) SubscribeID(evname eventtype.EventType, id interface{}, callBack dispatcheri.Callback)
SubscribeID subscribes a callback to events events with the given name. The user-provided unique id can be used to unsubscribe via UnsubscribeID.
func (*Dispatcher) UnsubscribeAllID ¶
func (d *Dispatcher) UnsubscribeAllID(id interface{}) int
UnsubscribeAllID removes all subscribed callbacks with the specified unique id from all events. Returns the number of subscriptions removed.
func (*Dispatcher) UnsubscribeID ¶
func (d *Dispatcher) UnsubscribeID(evname eventtype.EventType, id interface{}) int
UnsubscribeID removes all subscribed callbacks with the specified unique id
from the specified event.
Returns the number of subscriptions removed.