This commit is contained in:
jackdaw@loafle.com 2017-04-17 13:43:43 +09:00
parent aa2f7c2003
commit f958610bbf

View File

@ -5,6 +5,13 @@ import (
"sync"
)
type Observer interface {
Add(id string, ch chan interface{}) error
Remove(id string, rch chan interface{}) error
Notify(id string, arg interface{}) error
}
type observer struct {
mtx sync.Mutex
events map[string][]chan interface{}
@ -80,6 +87,10 @@ func init() {
// interface
func GetInstance() Observer {
return _observer
}
func Add(id string, ch chan interface{}) error {
return _observer.Add(id, ch)
}