32 lines
498 B
Go
32 lines
498 B
Go
|
// 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
|
||
|
}
|
||
|
|
||
|
|