on refresh, recreate raw too, because i dont wanna be leaking by not Closing on refresh

master
bel 2023-03-25 10:13:25 -06:00
parent 50e89492cf
commit 51ae1b27b4
2 changed files with 5 additions and 2 deletions

View File

@ -13,8 +13,8 @@ type Input interface {
}
func New(ctx context.Context) Input {
src := raw.New(ctx)
return wrap.New(ctx, func() button.Parser {
src := raw.New(ctx)
return button.New(ctx, src)
})
}

View File

@ -33,7 +33,10 @@ func NewRefresh(newWrap func() Wrap, ch <-chan os.Signal) *Refresh {
return
case sig := <-ch:
log.Println("refreshing for", sig)
result.input = newWrap()
newInput := newWrap()
oldInput := result.input
result.input = newInput
oldInput.Close()
}
}
}()