From 12596bfcfdb5ab16ef1741567936de5b0ca23d46 Mon Sep 17 00:00:00 2001 From: Warren Fernandes Date: Sun, 13 Nov 2016 14:09:17 -0700 Subject: [PATCH] Ranges over channel instead of using select Signed-off-by: Warren Fernandes --- eventer.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/eventer.go b/eventer.go index 2d5eb7f8..09672ba4 100644 --- a/eventer.go +++ b/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 } } }()