From f958610bbf0bf11d10f759a14bde44835e4d25f6 Mon Sep 17 00:00:00 2001 From: "jackdaw@loafle.com" Date: Mon, 17 Apr 2017 13:43:43 +0900 Subject: [PATCH] . --- observer/observer.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/observer/observer.go b/observer/observer.go index 725b944..35fc4a1 100644 --- a/observer/observer.go +++ b/observer/observer.go @@ -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) }