Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit ca1eeb5

Browse files
committed
feat: add event bus wrapper
1 parent 355437f commit ca1eeb5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

events.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package pluginlib
2+
3+
import "github.com/asaskevich/EventBus"
4+
5+
var bus = EventBus.New()
6+
7+
func Subscribe(eventName string, fn interface{}) error {
8+
return bus.Subscribe(eventName, fn)
9+
}
10+
11+
func Unsubscribe(eventName string, fn interface{}) error {
12+
return bus.Unsubscribe(eventName, fn)
13+
}
14+
15+
func Publish(eventName string, args ...interface{}) {
16+
bus.Publish(eventName, args)
17+
}

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module github.com/getstackhead/pluginlib
22

33
go 1.17
4+
5+
require github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef

0 commit comments

Comments
 (0)