io/router: expand Router.Add to accept multiple events

Niver API and useful for testing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-27 09:08:56 +01:00
parent a995e9ea6c
commit 5a3ffad00a
+3 -1
View File
@@ -79,7 +79,8 @@ func (q *Router) Frame(ops *op.Ops) {
} }
} }
func (q *Router) Add(e event.Event) bool { func (q *Router) Add(events ...event.Event) bool {
for _, e := range events {
switch e := e.(type) { switch e := e.(type) {
case profile.Event: case profile.Event:
q.profile = e q.profile = e
@@ -88,6 +89,7 @@ func (q *Router) Add(e event.Event) bool {
case key.EditEvent, key.Event, key.FocusEvent: case key.EditEvent, key.Event, key.FocusEvent:
q.kqueue.Push(e, &q.handlers) q.kqueue.Push(e, &q.handlers)
} }
}
return q.handlers.HadEvents() return q.handlers.HadEvents()
} }