From 9c38e101d21c870365037a3ec2b5f592beab9c79 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 9 Nov 2020 20:39:04 -0500 Subject: [PATCH] Remove internal msg in spinner so all tick msgs can be caught externally --- spinner/spinner.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spinner/spinner.go b/spinner/spinner.go index 824507a..2463814 100644 --- a/spinner/spinner.go +++ b/spinner/spinner.go @@ -148,15 +148,11 @@ type TickMsg struct { Time time.Time } -type startTick struct{} - // Update is the Tea update function. This will advance the spinner one frame // every time it's called, regardless the message passed, so be sure the logic // is setup so as not to call this Update needlessly. func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { switch msg.(type) { - case startTick: - return m, m.tick() case TickMsg: m.frame++ if m.frame >= len(m.Frames) { @@ -189,7 +185,7 @@ func (m Model) View() string { // Tick is the command used to advance the spinner one frame. func Tick() tea.Msg { - return startTick{} + return TickMsg{Time: time.Now()} } func (m Model) tick() tea.Cmd {