diff --git a/events.go b/events.go new file mode 100644 index 0000000..687e220 --- /dev/null +++ b/events.go @@ -0,0 +1,17 @@ +package pluginlib + +import "github.com/asaskevich/EventBus" + +var bus = EventBus.New() + +func Subscribe(eventName string, fn interface{}) error { + return bus.Subscribe(eventName, fn) +} + +func Unsubscribe(eventName string, fn interface{}) error { + return bus.Unsubscribe(eventName, fn) +} + +func Publish(eventName string, args ...interface{}) { + bus.Publish(eventName, args) +} diff --git a/go.mod b/go.mod index ceb4f7a..08725b6 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/getstackhead/pluginlib go 1.17 + +require github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef