func (bus *EventBus) Publish(topic string, args ...interface{}) {
	bus.lock.Lock() // will unlock if handler is not found or always after setUpPublish
	defer bus.lock.Unlock()
	if handlers, ok := bus.handlers[topic]; ok && 0 < len(handlers) {
		// Handlers slice may be changed by removeHandler and Unsubscribe during iteration,
		// so make a copy and iterate the copied slice.
		copyHandlers := make([]*eventHandler, 0, len(handlers))
		copyHandlers = append(copyHandlers, handlers...)
		for i, handler := range copyHandlers {
			if handler.flagOnce {
				bus.removeHandler(topic, i)
			}
			if !handler.async {
				bus.doPublish(handler, topic, args...)
			} else {
				bus.wg.Add(1)
				if handler.transactional {
					handler.Lock()
				}
				go bus.doPublishAsync(handler, topic, args...)
			}
		}
	}
}
func (bus *EventBus) Publish(topic string, args ...interface{}) {
	bus.lock.Lock() // will unlock if handler is not found or always after setUpPublish
	defer bus.lock.Unlock()
	if handlers, ok := bus.handlers[topic]; ok && 0 < len(handlers) {
		// Handlers slice may be changed by removeHandler and Unsubscribe during iteration,
		// so make a copy and iterate the copied slice.
		copyHandlers := make([]*eventHandler, 0, len(handlers))
		copyHandlers = append(copyHandlers, handlers...)
		for i, handler := range copyHandlers {
			if handler.flagOnce {
				bus.removeHandler(topic, i)
			}
			if !handler.async {
				bus.doPublish(handler, topic, args...)
			} else {
				bus.wg.Add(1)
				if handler.transactional {
					handler.Lock()
				}
				go bus.doPublishAsync(handler, topic, args...)
			}
		}
	}
}
func ( bus * EventBus ) Publish ( topic string , args ... interface { } ) { bus . lock . Lock ( ) // will unlock if handler is not found or always after setUpPublish defer bus . lock . Unlock ( ) if handlers , ok := bus . handlers [ topic ] ; ok && 0 < len ( handlers ) { // Handlers slice may be changed by removeHandler and Unsubscribe during iteration, // so make a copy and iterate the copied slice. copyHandlers := make ( [ ] * eventHandler , 0 , len ( handlers ) ) copyHandlers = append ( copyHandlers , handlers ... ) for i , handler := range copyHandlers { if handler . flagOnce { bus . removeHandler ( topic , i ) } if ! handler . async { bus . doPublish ( handler , topic , args ... ) } else { bus . wg . Add ( 1 ) if handler . transactional { handler . Lock ( ) } go bus . doPublishAsync ( handler , topic , args ... ) } } } }
// Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.
Publish executes callback defined for a topic . Any additional argument will be transferred to the callback .