aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfaiface <faiface@ksp.sk>2017-08-20 12:32:09 +0200
committerfaiface <faiface@ksp.sk>2017-08-20 12:32:09 +0200
commitcf0fe08923f24b31c7f1064d950bf4410c1eafff (patch)
treeaf3cce1564ef4ea01688bc298995843e5827580d
parent44eee719412cde90331eab4ff28ae5ff2dbbcf7a (diff)
downloadgui-cf0fe08923f24b31c7f1064d950bf4410c1eafff.zip
event: add Matches
-rw-r--r--event/dispatch.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/event/dispatch.go b/event/dispatch.go
index 738161a..89d1cae 100644
--- a/event/dispatch.go
+++ b/event/dispatch.go
@@ -26,6 +26,20 @@ func Sscan(event string, a ...interface{}) {
}
}
+func Matches(pattern, event string) bool {
+ p := strings.Split(pattern, Sep)
+ e := strings.Split(event, Sep)
+ if len(p) > len(e) {
+ return false
+ }
+ for i := range p {
+ if p[i] != e[i] {
+ return false
+ }
+ }
+ return true
+}
+
type Dispatch struct {
mu sync.Mutex
handlers []func(event string) bool