From 88e4df4055afafffa1bf240ea6bbaab6f3f2ed2e Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 11 May 2020 17:37:23 -0400 Subject: [PATCH] Update spinner example so it works with the spinner version in master --- examples/spinner/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/spinner/main.go b/examples/spinner/main.go index ad98e52..056216b 100644 --- a/examples/spinner/main.go +++ b/examples/spinner/main.go @@ -1,7 +1,6 @@ package main import ( - "errors" "fmt" "log" @@ -83,14 +82,17 @@ func view(model tea.Model) string { return fmt.Sprintf("\n\n %s Loading forever...press q to quit\n\n", s) } -func subscriptions(_ tea.Model) tea.Subs { +func subscriptions(model tea.Model) tea.Subs { + m, ok := model.(Model) + if !ok { + return nil + } + + sub, err := spinner.MakeSub(m.spinner) + if err != nil { + return nil + } return tea.Subs{ - "tick": func(model tea.Model) tea.Msg { - m, ok := model.(Model) - if !ok { - return errMsg(errors.New("could perform assertion on model in subscription")) - } - return spinner.Sub(m.spinner) - }, + "tick": sub, } }