Ranges over channel instead of using select

Signed-off-by: Warren Fernandes <warren.f.fernandes@gmail.com>
This commit is contained in:
Warren Fernandes 2016-11-13 14:09:17 -07:00
parent 370b296651
commit 12596bfcfd
1 changed files with 5 additions and 8 deletions

View File

@ -129,14 +129,11 @@ func (e *eventer) Once(n string, f func(s interface{})) (err error) {
out := e.Subscribe()
go func() {
ProcessEvents:
for {
select {
case evt := <-out:
if evt.Name == n {
f(evt.Data)
e.Unsubscribe(out)
break ProcessEvents
}
for evt := range out {
if evt.Name == n {
f(evt.Data)
e.Unsubscribe(out)
break ProcessEvents
}
}
}()