summaryrefslogtreecommitdiff
path: root/plugins/events
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-13 13:55:20 +0300
committerValery Piashchynski <[email protected]>2020-10-13 13:55:20 +0300
commit0dc44d54cfcc9dd3fa09a41136f35a9a8d26b994 (patch)
treeffcb65010bebe9f5b5436192979e64b2402a6ec0 /plugins/events
parent08d6b6b7f773f83b286cd48c1a0fbec9a62fb42b (diff)
Initial commit of RR 2.0v2.0.0-alpha1
Diffstat (limited to 'plugins/events')
-rw-r--r--plugins/events/broadcaster.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/events/broadcaster.go b/plugins/events/broadcaster.go
new file mode 100644
index 00000000..778b307d
--- /dev/null
+++ b/plugins/events/broadcaster.go
@@ -0,0 +1,24 @@
+package events
+
+type EventListener interface {
+ Handle(event interface{})
+}
+
+type EventBroadcaster struct {
+ listeners []EventListener
+}
+
+func NewEventBroadcaster() *EventBroadcaster {
+ return &EventBroadcaster{}
+}
+
+func (eb *EventBroadcaster) AddListener(l EventListener) {
+ // todo: threadcase
+ eb.listeners = append(eb.listeners, l)
+}
+
+func (eb *EventBroadcaster) Push(e interface{}) {
+ for _, l := range eb.listeners {
+ l.Handle(e)
+ }
+}