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" "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 { type observer struct {
mtx sync.Mutex mtx sync.Mutex
events map[string][]chan interface{} events map[string][]chan interface{}
@ -80,6 +87,10 @@ func init() {
// interface // interface
func GetInstance() Observer {
return _observer
}
func Add(id string, ch chan interface{}) error { func Add(id string, ch chan interface{}) error {
return _observer.Add(id, ch) return _observer.Add(id, ch)
} }