jx/internal/folio/events.go

32 lines
498 B
Go
Raw Normal View History

2024-10-09 23:03:52 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package folio
import (
"errors"
_ "gitea.rosskeen.house/pylon/luaruntime"
_ "fmt"
)
type EventHandler string
type Events map[EventType]EventHandler
var (
ErrInvalidHandler error = errors.New("Invalid event handler")
)
func NewEvents() *Events {
e := make(Events)
return &e
}
func (e *Events) Set(t EventType, h EventHandler) (err error) {
if err = t.Validate(); err == nil {
(*e)[t] = h
}
return
}