implement ui handle waiter (#1930)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2023-07-12 13:14:54 -04:00
committed by GitHub
parent 38efe4ec5f
commit 4fc17edd14
4 changed files with 37 additions and 17 deletions
+10 -2
View File
@@ -12,7 +12,11 @@ import (
syftEvent "github.com/anchore/syft/syft/event"
)
var _ bubbly.EventHandler = (*Handler)(nil)
var _ interface {
bubbly.EventHandler
bubbly.MessageListener
bubbly.HandleWaiter
} = (*Handler)(nil)
type HandlerConfig struct {
TitleWidth int
@@ -61,8 +65,12 @@ func New(cfg HandlerConfig) *Handler {
return h
}
func (m *Handler) Update(msg tea.Msg) {
func (m *Handler) OnMessage(msg tea.Msg) {
if msg, ok := msg.(tea.WindowSizeMsg); ok {
m.WindowSize = msg
}
}
func (m *Handler) Wait() {
m.Running.Wait()
}