mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Split Dispatcher interface and use it across application
This commit is contained in:
@@ -2,12 +2,19 @@ package dispatcher
|
||||
|
||||
import "github.com/asaskevich/EventBus"
|
||||
|
||||
// TODO: split on 2 interfaces and use them across the application
|
||||
type EventDispatcher interface {
|
||||
type Subscriber interface {
|
||||
Subscribe(topic string, fn interface{})
|
||||
}
|
||||
|
||||
type Emitter interface {
|
||||
Emit(topic string, args ...interface{})
|
||||
}
|
||||
|
||||
type Dispatcher interface {
|
||||
Subscriber
|
||||
Emitter
|
||||
}
|
||||
|
||||
type localEventDispatcher struct {
|
||||
bus EventBus.Bus
|
||||
}
|
||||
@@ -20,7 +27,7 @@ func (d *localEventDispatcher) Emit(topic string, args ...interface{}) {
|
||||
d.bus.Publish(topic, args...)
|
||||
}
|
||||
|
||||
func New() EventDispatcher {
|
||||
func New() Dispatcher {
|
||||
return &localEventDispatcher{
|
||||
bus: EventBus.New(),
|
||||
}
|
||||
|
Reference in New Issue
Block a user