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

(v2) Proposal: program execution flow #1136

Open
aymanbagabas opened this issue Sep 11, 2024 · 3 comments
Open

(v2) Proposal: program execution flow #1136

aymanbagabas opened this issue Sep 11, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@aymanbagabas
Copy link
Member

Currently, Bubble Tea programs has the following methods to start and run a program.

To keep the API similar to other Go packages, we could change the API to be as follows:

  • Start() error starts the program and event loop
  • Wait() error waits for the event loop to finish and exit
  • Run() error becomes a helper that starts and waits for the program
  • Kill() error kills the program and forces the event loop to stop

With this, we would expose a program.Model that has the final model after the program exits. During the lifetime of the program, program.Model would be nil. This is similar to the exec.Cmd API in the standard library.

@aymanbagabas aymanbagabas added the enhancement New feature or request label Sep 11, 2024
@aymanbagabas aymanbagabas added this to the v2.0.0 milestone Sep 11, 2024
@tauraamui
Copy link

Presumably this would result in needing to provide a V2 version of the library, how would you most prefer to do this? Via a V2 branch or a v2 submodule?

@caarlos0
Copy link
Member

caarlos0 commented Jan 6, 2025

@aymanbagabas the only problem I see with this is that people might still be using the currently deprecated Start(), which waits for the program to quit.

If we do this new proposed API, Start becomes "undeprecated", with different behavior.
Not sure how fine this is, but would def have to be very specific about this.
Another idea would be to make a "tealint" of sort, which check for this kind of stuff (and maybe more?) - seems like a rather big project though.

@caarlos0
Copy link
Member

caarlos0 commented Jan 6, 2025

Presumably this would result in needing to provide a V2 version of the library, how would you most prefer to do this? Via a V2 branch or a v2 submodule?

Definitely for v2, haven't decided on specifics yet, as it also depends on whether we'll want to continue maintaining v1, e.g., with GoReleaser I simply said "main is now v2", changed the module paths, and that was it.

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

No branches or pull requests

5 participants