From 610aef4f7ed8e34174ed7010de9f0490d900f4b9 Mon Sep 17 00:00:00 2001 From: bel Date: Fri, 24 Mar 2023 22:15:36 -0600 Subject: [PATCH] rebuild parser on refresh --- src/device/input/input.go | 5 +++-- src/device/input/wrap/wrap.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/device/input/input.go b/src/device/input/input.go index f1dfd15..c3ca210 100644 --- a/src/device/input/input.go +++ b/src/device/input/input.go @@ -14,6 +14,7 @@ type Input interface { func New(ctx context.Context) Input { src := raw.New(ctx) - parser := button.New(ctx, src) - return wrap.New(ctx, parser) + return wrap.New(ctx, func() button.Parser { + return button.New(ctx, src) + }) } diff --git a/src/device/input/wrap/wrap.go b/src/device/input/wrap/wrap.go index 3d1c82f..582fa79 100644 --- a/src/device/input/wrap/wrap.go +++ b/src/device/input/wrap/wrap.go @@ -12,9 +12,9 @@ type Wrap interface { Close() } -func New(ctx context.Context, src button.Parser) Wrap { +func New(ctx context.Context, srcFunc func() button.Parser) Wrap { maker := func() Wrap { - return src + return srcFunc() } if os.Getenv("WRAP_BUFFERED") == "true" { oldMaker := maker