From ecd5df9a4941aca9692388dd6ebb21d5f4b26498 Mon Sep 17 00:00:00 2001 From: MrWaggel Date: Sat, 13 Aug 2016 13:43:04 +0200 Subject: [PATCH] Added a EvtStream member function ResetHandlers() A feature that I missed, it clears all the defined termui.Handle() calls. Also a cleaner fix for https://github.com/gizak/termui/issues/92 --- events.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/events.go b/events.go index 177bbb4..6627f89 100644 --- a/events.go +++ b/events.go @@ -221,6 +221,13 @@ func findMatch(mux map[string]func(Event), path string) string { return pattern } +// Remove all existing defined Handlers from the map +func (es *EvtStream) ResetHandlers() { + for Path, _ := range es.Handlers { + delete(es.Handlers, Path) + } + return +} func (es *EvtStream) match(path string) string { return findMatch(es.Handlers, path)