How do I print something after I exit the app model using tea.Quit? #1662
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The "garbage" is almost certainly a leftover escape sequence from the last frame Bubble Tea rendered before it handed control back. Your print code is fine — the fix is to tell Bubble Tea to clear the frame on exit. Three approaches, increasingly thorough: 1. Return an empty view on quitIf your model has a func (m AppModel) View() string {
if m.quitting {
return ""
}
// …your normal rendering
}
func (m AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// …
if shouldQuit {
m.quitting = true
return m, tea.Quit
}
}The Quit command causes one final render, which with an empty view leaves a clean terminal. That alone fixes the overwhelming majority of "garbage on exit" reports. 2. Use
|
Beta Was this translation helpful? Give feedback.

The "garbage" is almost certainly a leftover escape sequence from the last frame Bubble Tea rendered before it handed control back. Your print code is fine — the fix is to tell Bubble Tea to clear the frame on exit.
Three approaches, increasingly thorough:
1. Return an empty view on quit
If your model has a
quitting bool(or similar state), makeView()return""once you've triggeredtea.Quit:The Quit command causes one final rend…