change NewEventHook to return pointer

This commit is contained in:
raziman 2021-02-19 12:08:56 +08:00
parent 4fa99d1043
commit e8f0b306f0
2 changed files with 7 additions and 3 deletions

View File

@ -1,9 +1,10 @@
package main
import (
"github.com/issadarkthing/gomu/anko"
"github.com/issadarkthing/gomu/hook"
"github.com/rivo/tview"
"github.com/ztrue/tracerr"
"github.com/issadarkthing/gomu/anko"
)
var VERSION = "N/A"
@ -25,6 +26,7 @@ type Gomu struct {
panels []Panel
args Args
anko anko.Anko
hook *hook.EventHook
}
// Creates new instance of gomu with default values
@ -33,6 +35,7 @@ func newGomu() *Gomu {
gomu := &Gomu{
command: newCommand(),
anko: anko.NewAnko(),
hook: hook.NewEventHook(),
}
return gomu

View File

@ -4,8 +4,8 @@ type EventHook struct {
events map[string][]func()
}
func NewEventHook() EventHook {
return EventHook{make(map[string][]func())}
func NewEventHook() *EventHook {
return &EventHook{make(map[string][]func())}
}
func (e *EventHook) AddHook(eventName string, handler func()) {
@ -13,6 +13,7 @@ func (e *EventHook) AddHook(eventName string, handler func()) {
hooks, ok := e.events[eventName]
if !ok {
e.events[eventName] = []func(){handler}
return
}
e.events[eventName] = append(hooks, handler)