Rename Dispatcher to Bus
This commit is contained in:
parent
5b42d91781
commit
a2269cd439
|
@ -1,14 +1,14 @@
|
||||||
package events
|
package events
|
||||||
|
|
||||||
type Dispatcher struct {
|
type Bus struct {
|
||||||
topics map[string]*topic
|
topics map[string]*topic
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *Dispatcher {
|
func New() *Bus {
|
||||||
return &Dispatcher{topics: make(map[string]*topic)}
|
return &Bus{topics: make(map[string]*topic)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dispatcher) On(event string, receiver interface{}) error {
|
func (d *Bus) On(event string, receiver interface{}) error {
|
||||||
// TODO: make thread safe
|
// TODO: make thread safe
|
||||||
t, hasTopic := d.topics[event]
|
t, hasTopic := d.topics[event]
|
||||||
if !hasTopic {
|
if !hasTopic {
|
||||||
|
@ -25,7 +25,7 @@ func (d *Dispatcher) On(event string, receiver interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dispatcher) Fire(event string, args ...interface{}) {
|
func (d *Bus) Fire(event string, args ...interface{}) {
|
||||||
// TODO: make thead safe
|
// TODO: make thead safe
|
||||||
topic, hasTopic := d.topics[event]
|
topic, hasTopic := d.topics[event]
|
||||||
if !hasTopic {
|
if !hasTopic {
|
Loading…
Reference in a new issue