mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Programs should take an init type/function as the first argument
This is in line with the way Elm works. Also update examples.
This commit is contained in:
@@ -21,12 +21,16 @@ type TickMsg struct{}
|
||||
|
||||
func main() {
|
||||
// Initialize our program
|
||||
p := tea.NewProgram(Model(5), update, view, []tea.Sub{tick})
|
||||
p := tea.NewProgram(initialize, update, view, []tea.Sub{tick})
|
||||
if err := p.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func initialize() (tea.Model, tea.Cmd) {
|
||||
return Model(5), nil
|
||||
}
|
||||
|
||||
// Update is called when messages are recived. The idea is that you inspect
|
||||
// the message and update the model (or send back a new one) accordingly. You
|
||||
// can also return a commmand, which is a function that peforms I/O and
|
||||
|
||||
Reference in New Issue
Block a user