.
This commit is contained in:
parent
aa2f7c2003
commit
f958610bbf
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user