Rename util.config.Watcher -> util.config.Broadcaster.
Watch is a widely used term in the codebase, which doesn't capture the key feature of this type: broadcasting a change to several listeners.
This commit is contained in:
@@ -97,24 +97,24 @@ func TestSimultaneousMerge(t *testing.T) {
|
||||
<-ch
|
||||
}
|
||||
|
||||
func TestWatcher(t *testing.T) {
|
||||
watch := NewWatcher()
|
||||
watch.Notify(struct{}{})
|
||||
func TestBroadcaster(t *testing.T) {
|
||||
b := NewBroadcaster()
|
||||
b.Notify(struct{}{})
|
||||
|
||||
ch := make(chan bool, 2)
|
||||
watch.Add(ListenerFunc(func(object interface{}) {
|
||||
b.Add(ListenerFunc(func(object interface{}) {
|
||||
if object != "test" {
|
||||
t.Errorf("Expected %s, Got %s", "test", object)
|
||||
}
|
||||
ch <- true
|
||||
}))
|
||||
watch.Add(ListenerFunc(func(object interface{}) {
|
||||
b.Add(ListenerFunc(func(object interface{}) {
|
||||
if object != "test" {
|
||||
t.Errorf("Expected %s, Got %s", "test", object)
|
||||
}
|
||||
ch <- true
|
||||
}))
|
||||
watch.Notify("test")
|
||||
b.Notify("test")
|
||||
<-ch
|
||||
<-ch
|
||||
}
|
||||
|
Reference in New Issue
Block a user