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

fix(tea): allocate msgs channel in constructor #180

Merged
merged 1 commit into from Jan 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions tea.go
Expand Up @@ -239,6 +239,7 @@ func NewProgram(model Model, opts ...ProgramOption) *Program {
initialModel: model,
output: os.Stdout,
input: os.Stdin,
msgs: make(chan Msg),
CatchPanics: true,
}

Expand All @@ -252,8 +253,6 @@ func NewProgram(model Model, opts ...ProgramOption) *Program {

// StartReturningModel initializes the program. Returns the final model.
func (p *Program) StartReturningModel() (Model, error) {
p.msgs = make(chan Msg)

var (
cmds = make(chan Cmd)
errs = make(chan error)
Expand Down Expand Up @@ -554,9 +553,7 @@ func (p *Program) Start() error {
// This method is currently provisional. The method signature may alter
// slightly, or it may be removed in a future version of this package.
func (p *Program) Send(msg Msg) {
if p.msgs != nil {
p.msgs <- msg
}
p.msgs <- msg
}

// Quit is a convenience function for quitting Bubble Tea programs. Use it
Expand Down