Skip to content
Myr

Minor simplification to countdown example

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 9a3a101 · Browse files · 1 file+3 added−3 removed
This commit

State

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

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:examples/countdown/main.go+3 added-3 removed
30 unmodified lines
31 lastTick time.Time32}3334func (m model) Init() tea.Cmd {35 return m.tick()35 return tick()36}3738func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {39 switch msg := msg.(type) {
3 unmodified lines
43 if t.After(m.timeout) {44 return m, tea.Quit45 }46 m.lastTick = t47 return m, m.tick()47 return m, tick()4849 case tea.KeyMsg:50 switch msg.String() {51 case "ctrl+c", "q":
10 unmodified lines
62 millis := t % 1000 / 1063 return fmt.Sprintf("This program will quit in %02d:%02d\n", secs, millis)64}6566func (m model) tick() tea.Cmd {66func tick() tea.Cmd {67 return tea.Tick(time.Duration(interval), func(t time.Time) tea.Msg {68 return tickMsg(t)69 })70}