removing the old test UI codes

This commit is contained in:
2026-01-12 20:03:32 +00:00
parent 3d52caeb04
commit e7bfc5c81f
21 changed files with 30 additions and 395 deletions
+38
View File
@@ -0,0 +1,38 @@
// Package events defines a simple event handler system
package events
import "sync"
type Handler func(event any)
type Bus struct {
mu sync.RWMutex
handlers map[string][]Handler
}
func NewBus() *Bus {
return &Bus{
handlers: make(map[string][]Handler),
}
}
func (b *Bus) On(eventType any, h Handler) {
key := typeKey(eventType)
b.mu.Lock()
defer b.mu.Unlock()
b.handlers[key] = append(b.handlers[key], h)
}
func (b *Bus) Emit(event any) {
key := typeKey(event)
b.mu.RLock()
handlers := append([]Handler{}, b.handlers[key]...)
b.mu.RUnlock()
for _, h := range handlers {
h(event)
}
}
+13
View File
@@ -0,0 +1,13 @@
package events
import (
"esdi/tui/internal/models"
)
type Error struct {
Error error
}
type WindowCreated struct {
Window models.Window
}
+7
View File
@@ -0,0 +1,7 @@
package events
import "fmt"
func typeKey(v any) string {
return fmt.Sprintf("%T", v)
}