Minor simplification to countdown example

This commit is contained in:
Christian Rocha 2020-10-25 17:08:58 -04:00
parent 9a3a101244
commit 93adce2131
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
1 changed files with 3 additions and 3 deletions

View File

@ -32,7 +32,7 @@ type model struct {
} }
func (m model) Init() tea.Cmd { func (m model) Init() tea.Cmd {
return m.tick() return tick()
} }
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
@ -44,7 +44,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit return m, tea.Quit
} }
m.lastTick = t m.lastTick = t
return m, m.tick() return m, tick()
case tea.KeyMsg: case tea.KeyMsg:
switch msg.String() { switch msg.String() {
@ -63,7 +63,7 @@ func (m model) View() string {
return fmt.Sprintf("This program will quit in %02d:%02d\n", secs, millis) return fmt.Sprintf("This program will quit in %02d:%02d\n", secs, millis)
} }
func (m model) tick() tea.Cmd { func tick() tea.Cmd {
return tea.Tick(time.Duration(interval), func(t time.Time) tea.Msg { return tea.Tick(time.Duration(interval), func(t time.Time) tea.Msg {
return tickMsg(t) return tickMsg(t)
}) })