diff --git a/event/registry.go b/event/registry.go index fd86889..68878ce 100644 --- a/event/registry.go +++ b/event/registry.go @@ -50,7 +50,7 @@ type registry struct { dispatcher func(r *registry, name string, ev ...interface{}) } -func NewRegistry() *registry { +func NewRegistry() EventRegistry { r := ®istry{events: make(map[string]*list.List)} r.Parallel() return r @@ -89,6 +89,14 @@ func (r *registry) Dispatch(name string, ev ...interface{}) { r.dispatcher(r, name, ev...) } +func (r *registry) ClearEvents(name string) { + r.Lock() + defer r.Unlock() + if l, ok := r.events[name]; ok { + l.Init() + } +} + func (r *registry) Parallel() { r.dispatcher = (*registry).parallelDispatch }