Components don't implement tea.Model #162
ghostsquad
started this conversation in
Ideas
Replies: 1 comment
-
Hey @ghostsquad, just wanted to chime in here. The bubbles don't implement the I hope this helps to clarify! (That link has more details) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been doing a bit of research on
bubbles
and various of applications that use it, and in almost all cases, including inBubbles
itself, thetea.Model
interface is seldom actually followed. I believe the reason for this is that when runningUpdate
, parent components want (without a type assertion) to have all the other methods on the model.The problem with this (and I'll provide some examples below), is that it means the
tea.Model
interface is almost entirely useless except for the very top-levelapp
component. However, if the abstraction could be followed more closely it would allow more components to be composed together.Here's a concrete example of a component that doesn't implement
tea.Model
, and possible solutionsbubbles/viewport/viewport.go
Line 266 in cd2593c
Here's a synopsis of the methods that are needed to "control" or "inspect the state of" a
viewport
:The control methods could be made private, with an associated public
tea.Msg
.The inspect methods could be implemented as callbacks within the constructor. Example:
Though, this means that this might necessitate some design changes, as these don't return a
bool
instead they are called when the viewport is at the top. Thus, anyone using this cannot "ask" for the viewports state, instead, they must simply listen for when the state changes.I'm opening this as a discussion because I'm a new user to bubbletea and bubbles, and I found this to be an interesting discovery.
Beta Was this translation helpful? Give feedback.
All reactions