Skip to content

Commit

Permalink
Ranges over channel instead of using select
Browse files Browse the repository at this point in the history
Signed-off-by: Warren Fernandes <[email protected]>
  • Loading branch information
wfernandes committed Nov 13, 2016
1 parent 370b296 commit 12596bf
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions eventer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}()
Expand Down

0 comments on commit 12596bf

Please sign in to comment.