Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Creating overarching interface for all ui component models #371

Open
sanghunjlee opened this issue Apr 23, 2023 · 2 comments

Comments

@sanghunjlee
Copy link

I want to create an array of different bubbles UI components. The issue I've come across is that there is no great way to create an interface to group all of the components because each component exists as a separate package with each Model struct registered as separate type.

I was wondering why Init function isn't implemented for each component as such:

func (m Model) Init() tea.Cmd {
	return nil
}

And change the output type for the Update function:

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	...
}
@sanghunjlee sanghunjlee changed the title Missing Init function to allow implementing tea.Model interface Feature request: Implement Init function Apr 23, 2023
@sanghunjlee
Copy link
Author

After trying out an example, the implementation of the ui Model as tea.Model complicates the situation more as many of functions of ui components aren't implemented through tea.Model.

However, I'm wondering if creating a overarching interface for all the ui components could be helpful in the case of multi-component ui creation.

On that note, changing the title & keeping this thread open.

@sanghunjlee sanghunjlee changed the title Feature request: Implement Init function Feature request: Creating overarching interface for all ui component models Apr 23, 2023
@luhring
Copy link

luhring commented Apr 18, 2024

I ran into this, too... I'm curious, why don't Bubbles implement tea.Model?

In my case, I'm working on an app that asks different kinds of questions, and uses different components depending on the kind of question. So far it's been nice to generalize the interchangeable components with the type tea.Model, since it provides more type guarantee than just interface{}.

I have some of my own components, but I went to reach for textinput.Model because it handles text input so well. But then I got an error that it doesn't implement tea.Model, and I thought "this can't be right...". It looks like if only it implemented Init() and returned a nil command, this would work?

Eager to hear more about the design choice here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants