feed.go
1 package event 2 3 type Subscription chan <-Payload 4 5 type Feed struct { 6 subscribers []Subscription 7 } 8 9 // Subscribe adds a channel to the feed. 10 func (f *Feed) Subscribe(channel Subscription) { // @todo think about returning a subscription like prysm 11 f.subscribers = append(f.subscribers, channel) 12 } 13 14 // Send sends a payload to all the subscribers for the specific feed. 15 func (f *Feed) Send(value Payload) { 16 // @todo is this good enough for now? 17 for _, sub := range f.subscribers { 18 sub <- value 19 } 20 }