v0.19.0
Final Model Access
This release features Program.StartReturningModel
, a handy alternative start method for returning the final Model
after a Program
exits. This makes it easy to access data collected in a Bubble Tea program while still working in an immutable fashion.
Here’s an example illustrating how it works:
type MyModel struct {
Name string
FaveCatColor string
}
p := tea.NewProgram(MyModel{})
// Return the final model when we're done
finalModel, err := p.StartReturningModel()
if err != nil {
fmt.Println("Uh oh", err)
os.Exit(1)
}
// The final model is a generalized tea.Model, so be sure to assert it into
// your actual model type.
if m, ok := finalModel.(MyModel); ok {
fmt.Printf("Hello, %s. I have a %s kitty for you.\n", m.Name, m.FaveCatColor)
}
🤗 A big thanks to @Raphexion for both conceptualizing and executing this feature.
ANSI Compression, Now Opt-In
We’ve also made the ANSI compressor opt-in by default as we noticed that it was incurring a larger performance hit than we’d like in some cases. To enable the ANSI compressor just use the WithANSICompressor
program option:
tea.NewProgram(model, tea.WithANSICompressor())
Changelog
Here’s the full changelog for this release.
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter or The Fediverse.