Remove entire subscription model

It was a valiant effort, and the implementation was solid and
dependable, but at the end of the day we can achieve the same
functionality in a much simpler fashion with commands, especially
because Go is not held to the same restrictions as Elm.
This commit is contained in:
Christian Rocha
2020-05-12 17:56:30 -04:00
parent 82ddbb8e12
commit ade8203c21
13 changed files with 136 additions and 322 deletions

View File

@@ -22,7 +22,7 @@ type Model struct {
type errMsg error
func main() {
p := boba.NewProgram(initialize, update, view, subscriptions)
p := boba.NewProgram(initialize, update, view)
if err := p.Start(); err != nil {
fmt.Println(err)
os.Exit(1)
@@ -30,12 +30,12 @@ func main() {
}
func initialize() (boba.Model, boba.Cmd) {
m := spinner.NewModel()
m.Type = spinner.Dot
s := spinner.NewModel()
s.Type = spinner.Dot
return Model{
spinner: m,
}, nil
spinner: s,
}, spinner.Tick(s)
}
func update(msg boba.Msg, model boba.Model) (boba.Model, boba.Cmd) {
@@ -64,8 +64,9 @@ func update(msg boba.Msg, model boba.Model) (boba.Model, boba.Cmd) {
return m, nil
default:
m.spinner, _ = spinner.Update(msg, m.spinner)
return m, nil
var cmd boba.Cmd
m.spinner, cmd = spinner.Update(msg, m.spinner)
return m, cmd
}
}
@@ -88,18 +89,3 @@ func view(model boba.Model) string {
}
return str
}
func subscriptions(model boba.Model) boba.Subs {
m, ok := model.(Model)
if !ok {
return nil
}
sub, err := spinner.MakeSub(m.spinner)
if err != nil {
return nil
}
return boba.Subs{
"tick": sub,
}
}