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
This commit is contained in:
MrWaggel 2016-08-13 13:43:04 +02:00 committed by GitHub
parent 202925a536
commit ecd5df9a49

View File

@ -221,6 +221,13 @@ func findMatch(mux map[string]func(Event), path string) string {
return pattern 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 { func (es *EvtStream) match(path string) string {
return findMatch(es.Handlers, path) return findMatch(es.Handlers, path)