Every sends the time at which the timer ticked

This commit is contained in:
Christian Rocha
2020-05-05 14:26:06 -04:00
parent ac67237eab
commit d503d5dbf6
4 changed files with 49 additions and 27 deletions

View File

@@ -12,7 +12,11 @@ import (
type model int
type tickMsg struct{}
type tickMsg time.Time
func newTickMsg(t time.Time) tea.Msg {
return tickMsg(t)
}
func main() {
tea.AltScreen()
@@ -55,7 +59,7 @@ func update(message tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {
func subscriptions(_ tea.Model) tea.Subs {
return tea.Subs{
"tick": tea.Every(time.Second, tickMsg{}),
"tick": tea.Every(time.Second, newTickMsg),
}
}