mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-05-02 22:17:09 +08:00
change NewEventHook to return pointer
This commit is contained in:
parent
4fa99d1043
commit
e8f0b306f0
5
gomu.go
5
gomu.go
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user