Add unsubscribe to config

This commit is contained in:
Audrius Butkevicius 2015-06-28 20:09:10 +01:00
parent bb876eac82
commit c2ccab4361
1 changed files with 15 additions and 0 deletions

View File

@ -114,6 +114,21 @@ func (w *Wrapper) Subscribe(c Committer) {
w.sMut.Unlock()
}
// Unsubscribe de-registers the given handler from any future calls to
// configuration changes
func (w *Wrapper) Unsubscribe(c Committer) {
w.sMut.Lock()
for i := range w.subs {
if w.subs[i] == c {
copy(w.subs[i:], w.subs[i+1:])
w.subs[len(w.subs)-1] = nil
w.subs = w.subs[:len(w.subs)-1]
break
}
}
w.sMut.Unlock()
}
// Raw returns the currently wrapped Configuration object.
func (w *Wrapper) Raw() Configuration {
return w.cfg