(v2) Is Bubbletea 2 going back to Init() (tea.Cmd)? #1336
-
I had been working on your alpha version. In the notes, it was noted in the alpha release notes that one of the changes was to move from Again, thank you or all you do. Looking forward to your answer. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
We are so flattered you're not only trying In short, yes, we've settled on type model int
func (m model) Init() (tea.Model, tea.Cmd) {
m = 5 // we can initialize the model here
return m, nil
}
p := tea.NewProgram(model(5)) // but we can also do it here In theory, it would be nice to specify the type and eliminate the argument with generics, à la: p := tea.NewProgram[model]() …but there's not way to enforce Look for a new release soon, and let us know if you have any more questions! |
Beta Was this translation helpful? Give feedback.
We are so flattered you're not only trying
v2
, but bleeding edgev2-exp
to boot!In short, yes, we've settled on
Init() tea.Cmd
. After trying many different API shapes we've decided that's still the best way to do things, as one still has to initialize the model when passing it to theProgram
as an argument, which becomes a bit redundant withInit() (tea.Model, tea.Cmd)
:In theory, it would be nice to specify the type and eliminate the argument with generics, à la:
…but there…