Re:Bubble Tea: fun, functional and stateful way to build ter...
by sriram_malhar on Tuesday May 10, 2022 @01:53PM
(#31330144)
Well, it does matter, or rather, it could matter.
For example, say you needed an undo/redo mechanism. If the model were guaranteed to be immutable model, you could simply hang on to the previous models as a sequence of state changes; undoing/redoing is trivial. If the model is mutable, then the undo/redo system has to defensively make a copy before update is called
Re:Bubble Tea: fun, functional and stateful way to build ter...
by christianrocha on Tuesday May 10, 2022 @05:30PM
(#31332981)
Do note, however, that paints will only occur if the output changes, and only lines that have changed will be redrawn.
It's actually the `tea.Msg` that causes re-renders. Here's the code: https://github.com/charmbracelet/bubbletea/blob/v0.20.0/tea.....
tea.Msg is, in Redux land, an "action" that triggers some state updates and _always_ triggers a re-render, even if nothing changes.
This is elm-like, but we have to understand the limitations of what we're working with: a terminal with no way of (nicely) updating elements in place. It's essentially an immediate-mode UI, and so it always paints.