mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
feat: tea.Batch returns nil if all cmds are nil (#217)
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a09e0e80cb
commit
9a06319ff1
11
tea.go
11
tea.go
@@ -119,11 +119,18 @@ type Program struct {
|
||||
// }
|
||||
//
|
||||
func Batch(cmds ...Cmd) Cmd {
|
||||
if len(cmds) == 0 {
|
||||
var validCmds []Cmd
|
||||
for _, c := range cmds {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
validCmds = append(validCmds, c)
|
||||
}
|
||||
if len(validCmds) == 0 {
|
||||
return nil
|
||||
}
|
||||
return func() Msg {
|
||||
return batchMsg(cmds)
|
||||
return batchMsg(validCmds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user