Help us shape the future of Go! Take the 2026 Go Developer Survey

cmdbatch

package
v1.107.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package cmdbatch provides a fluent builder for batching tea.Cmd values.

This reduces boilerplate when building command slices in Update functions, following the Elm Architecture pattern of accumulating commands.

Usage:

return m, cmdbatch.New().
    Add(p.sidebar.Update(msg)).
    AddIf(p.working, p.spinner.Init()).
    Add(p.messages.Update(msg)).
    Batch()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder accumulates commands for batching.

func New

func New() *Builder

New creates a new command builder.

func (*Builder) Add

func (b *Builder) Add(cmd tea.Cmd) *Builder

Add appends a command to the batch (nil commands are ignored).

func (*Builder) AddAll

func (b *Builder) AddAll(cmds ...tea.Cmd) *Builder

AddAll appends multiple commands to the batch.

func (*Builder) AddIf

func (b *Builder) AddIf(condition bool, cmd tea.Cmd) *Builder

AddIf conditionally appends a command to the batch.

func (*Builder) Batch

func (b *Builder) Batch() tea.Cmd

Batch returns a batched command, or nil if no commands were added.

func (*Builder) Len

func (b *Builder) Len() int

Len returns the number of commands in the batch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL