Skip to content
Myr

Use model-based Tick commands in spinner examples

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent ee92bed · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:examples/spinner/main.go+1 added-1 removed
26 unmodified lines
27 return model{spinner: s}28}2930func (m model) Init() tea.Cmd {31 return spinner.Tick31 return m.spinner.Tick32}3334func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {35 switch msg := msg.(type) {
40 unmodified lines
modified:examples/spinners/main.go+3 added-3 removed
42 unmodified lines
43 spinner spinner.Model44}4546func (m model) Init() tea.Cmd {47 return spinner.Tick47 return m.spinner.Tick48}4950func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {51 switch msg := msg.(type) {
6 unmodified lines
58 if m.index <= 0 {59 m.index = len(spinners) - 160 }61 m.resetSpinner()62 return m, spinner.Tick62 return m, m.spinner.Tick63 case "l", "right":64 m.index++65 if m.index >= len(spinners) {66 m.index = 067 }68 m.resetSpinner()69 return m, spinner.Tick69 return m, m.spinner.Tick70 default:71 return m, nil72 }73 case spinner.TickMsg:
27 unmodified lines