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:
@@ -17,12 +17,16 @@ type tickMsg struct{}
|
||||
func main() {
|
||||
tea.Fullscreen()
|
||||
defer tea.ExitFullscreen()
|
||||
err := tea.NewProgram(model(5), update, view, []tea.Sub{tick}).Start()
|
||||
err := tea.NewProgram(initialize, update, view, []tea.Sub{tick}).Start()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func initialize() (tea.Model, tea.Cmd) {
|
||||
return model(5), nil
|
||||
}
|
||||
|
||||
func update(message tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {
|
||||
m, _ := mdl.(model)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user