Ranges over channel instead of using select
Signed-off-by: Warren Fernandes <warren.f.fernandes@gmail.com>
This commit is contained in:
parent
370b296651
commit
12596bfcfd
13
eventer.go
13
eventer.go
|
@ -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
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue