Documentation
¶
Index ¶
- type CallbackFunc
- type Event
- type EventBus
- func (eb *EventBus) Publish(topic string, data interface{})
- func (eb *EventBus) PublishAsync(topic string, data interface{})
- func (eb *EventBus) Subscribe(topic string) EventChannel
- func (eb *EventBus) SubscribeCallback(topic string, callable CallbackFunc)
- func (eb *EventBus) SubscribeChannel(topic string, ch EventChannel)
- type EventChannel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Data interface{} Topic string // contains filtered or unexported fields }
Event holds topic name and data
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus stores the information about subscribers interested for a particular topic
func (*EventBus) Publish ¶
Publish data to a topic and wait for all subscribers to finish This function creates a waitGroup internally. All subscribers must call Done() function on Event
func (*EventBus) PublishAsync ¶
PublishAsync data to a topic asynchronously This function returns a bool channel which indicates that all subscribers where called
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(topic string) EventChannel
Subscribe to a topic passing a EventChannel
func (*EventBus) SubscribeCallback ¶
func (eb *EventBus) SubscribeCallback(topic string, callable CallbackFunc)
SubscribeCallback provides a simple wrapper that allows to directly register CallbackFunc instead of channels
func (*EventBus) SubscribeChannel ¶ added in v1.0.0
func (eb *EventBus) SubscribeChannel(topic string, ch EventChannel)
Subscribe with a given Channel
type EventChannel ¶
type EventChannel chan Event
EventChannel is a channel which can accept an Event