Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
feat: return event data as interface when publish
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomasi committed Sep 4, 2021
1 parent b8902f4 commit 2e41ea8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion event_bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (eb *EventBus) PublishAsync(topic string, data interface{}) {

// 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 (eb *EventBus) Publish(topic string, data interface{}) {
func (eb *EventBus) Publish(topic string, data interface{}) interface{} {
wg := sync.WaitGroup{}
channels := eb.getSubscribingChannels(topic)
wg.Add(len(channels))
Expand All @@ -142,6 +142,8 @@ func (eb *EventBus) Publish(topic string, data interface{}) {
wg: &wg,
})
wg.Wait()

return data
}

// Subscribe to a topic passing a EventChannel.
Expand Down

0 comments on commit 2e41ea8

Please sign in to comment.