mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-26 13:49:21 +08:00
add comments
This commit is contained in:
parent
1f0e990e2a
commit
af336e1a60
@ -4,10 +4,12 @@ type EventHook struct {
|
||||
events map[string][]func()
|
||||
}
|
||||
|
||||
// NewNewEventHook returns new instance of EventHook
|
||||
func NewEventHook() *EventHook {
|
||||
return &EventHook{make(map[string][]func())}
|
||||
}
|
||||
|
||||
// AddHook accepts a function which will be executed when the event is emitted.
|
||||
func (e *EventHook) AddHook(eventName string, handler func()) {
|
||||
|
||||
hooks, ok := e.events[eventName]
|
||||
@ -19,6 +21,7 @@ func (e *EventHook) AddHook(eventName string, handler func()) {
|
||||
e.events[eventName] = append(hooks, handler)
|
||||
}
|
||||
|
||||
// RunHooks executes all hooks installed for an event.
|
||||
func (e *EventHook) RunHooks(eventName string) {
|
||||
|
||||
hooks, ok := e.events[eventName]
|
||||
|
Loading…
x
Reference in New Issue
Block a user