Documentation ¶
Index ¶
- type EventBus
- func (bus *EventBus) HasCallback(topic string) bool
- func (bus *EventBus) Publish(topic string, args ...interface{})
- func (bus *EventBus) Subscribe(topic string, fn interface{}) error
- func (bus *EventBus) SubscribeAsync(topic string, fn interface{}, transactional bool) error
- func (bus *EventBus) SubscribeOnce(topic string, fn interface{}) error
- func (bus *EventBus) SubscribeOnceAsync(topic string, fn interface{}) error
- func (bus *EventBus) Unsubscribe(topic string) error
- func (bus *EventBus) WaitAsync()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus - box for handlers and callbacks.
func (*EventBus) HasCallback ¶
HasCallback returns true if exists any callback subscribed to the topic.
func (*EventBus) Publish ¶
Publish executes callback defined for a topic. Any addional argument will be tranfered to the callback.
func (*EventBus) Subscribe ¶
Subscribe subscribes to a topic. Returns error if `fn` is not a function.
func (*EventBus) SubscribeAsync ¶
SubscribeAsync subscribes to a topic with an asynchronous callback Transactional determines whether subsequent callbacks for a topic are run serially (true) or concurrently (false) Returns error if `fn` is not a function.
func (*EventBus) SubscribeOnce ¶
SubscribeOnce subscribes to a topic once. Handler will be removed after executing. Returns error if `fn` is not a function.
func (*EventBus) SubscribeOnceAsync ¶
SubscribeOnceAsync subscribes to a topic once with an asyncrhonous callback Handler will be removed after executing. Returns error if `fn` is not a function.
func (*EventBus) Unsubscribe ¶
Unsubscribe removes callback defined for a topic. Returns error if there are no callbacks subscribed to the topic.