Update spinner example so it works with the spinner version in master

This commit is contained in:
Christian Rocha 2020-05-11 17:37:23 -04:00
parent 2a82e2a75e
commit 88e4df4055
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
1 changed files with 11 additions and 9 deletions

View File

@ -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,
}
}