refresh users global ch

This commit is contained in:
bel
2023-03-25 10:25:11 -06:00
parent 2113252e2d
commit 97cc3ae151
4 changed files with 34 additions and 13 deletions

View File

@@ -6,6 +6,15 @@ import (
"mayhem-party/src/device/input/button"
"os"
"os/signal"
"syscall"
)
var (
ChanSigUsr1 = func() chan os.Signal {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGUSR1)
return c
}()
)
type Refresh struct {
@@ -13,13 +22,11 @@ type Refresh struct {
input Wrap
}
func NewRefreshCh(sig os.Signal) <-chan os.Signal {
c := make(chan os.Signal, 1)
signal.Notify(c, sig)
return c
func NewRefresh(newWrap func() Wrap) *Refresh {
return NewRefreshWith(newWrap, ChanSigUsr1)
}
func NewRefresh(newWrap func() Wrap, ch <-chan os.Signal) *Refresh {
func NewRefreshWith(newWrap func() Wrap, ch <-chan os.Signal) *Refresh {
ctx, can := context.WithCancel(context.Background())
result := &Refresh{
can: can,