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

Commit 2e41ea8

Browse files
committed
feat: return event data as interface when publish
1 parent b8902f4 commit 2e41ea8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

event_bus.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (eb *EventBus) PublishAsync(topic string, data interface{}) {
130130

131131
// Publish data to a topic and wait for all subscribers to finish
132132
// This function creates a waitGroup internally. All subscribers must call Done() function on Event.
133-
func (eb *EventBus) Publish(topic string, data interface{}) {
133+
func (eb *EventBus) Publish(topic string, data interface{}) interface{} {
134134
wg := sync.WaitGroup{}
135135
channels := eb.getSubscribingChannels(topic)
136136
wg.Add(len(channels))
@@ -142,6 +142,8 @@ func (eb *EventBus) Publish(topic string, data interface{}) {
142142
wg: &wg,
143143
})
144144
wg.Wait()
145+
146+
return data
145147
}
146148

147149
// Subscribe to a topic passing a EventChannel.

0 commit comments

Comments
 (0)