From 2e41ea81d7f3085336e3402054b602997f2d8967 Mon Sep 17 00:00:00 2001 From: Dominik Tomasi Date: Sat, 4 Sep 2021 11:32:18 +0200 Subject: [PATCH] feat: return event data as interface when publish --- event_bus.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/event_bus.go b/event_bus.go index a5be70e..91961f8 100644 --- a/event_bus.go +++ b/event_bus.go @@ -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)) @@ -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.