Closed
Description
Currently, Bubble Tea programs has the following methods to start and run a program.
Start() error
starts the program and waits without returning a final model deprecatedRun() (Model, error)
starts the program and waitsWait()
waits for the program to finish (the aforementioned ones already wait for the program to exit, this is redundant)Kill()
kills the program (currently it only cancels the context) Related issues: Recover panics from within cmds goroutines #234 After a panic() the terminal input does not show #1127
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 loopWait() error
waits for the event loop to finish and exitRun() error
becomes a helper that starts and waits for the programKill() 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.