Skip to content

Commit

Permalink
expose if message send was abandoned in Send()
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Huang-Hobbs authored and Max Huang-Hobbs committed Feb 8, 2024
1 parent c7b351c commit e965e25
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,12 @@ func (p *Program) Start() error {
// If the program hasn't started yet this will be a blocking operation.
// If the program has already been terminated this will be a no-op, so it's safe
// to send messages after the program has exited.
func (p *Program) Send(msg Msg) {
func (p *Program) Send(msg Msg) bool {
select {
case <-p.ctx.Done():
return false
case p.msgs <- msg:
return true
}
}

Expand Down

0 comments on commit e965e25

Please sign in to comment.