From a72bf9128d83c88df5d0148205a1397a2921aa94 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 11 May 2020 17:33:28 -0400 Subject: [PATCH] Update spinner to use proper tea.Tick subscription --- spinner/spinner.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spinner/spinner.go b/spinner/spinner.go index 7f80005..0bfd06c 100644 --- a/spinner/spinner.go +++ b/spinner/spinner.go @@ -50,7 +50,7 @@ func NewModel() Model { } // TickMsg indicates that the timer has ticked and we should render a frame -type TickMsg struct{} +type TickMsg time.Time // Update is the Tea update function func Update(msg tea.Msg, m Model) (Model, tea.Cmd) { @@ -94,8 +94,7 @@ func MakeSub(model tea.Model) (tea.Sub, error) { if !ok { return nil, assertionErr } - return func() tea.Msg { - time.Sleep(time.Second / time.Duration(m.FPS)) - return TickMsg{} - }, nil + return tea.Tick(time.Second/time.Duration(m.FPS), func(t time.Time) tea.Msg { + return TickMsg(t) + }), nil }