Add 'Every' subscription for ticking with the system clock

This commit is contained in:
Christian Rocha
2020-05-05 13:36:46 -04:00
parent b50ee76165
commit ac67237eab
4 changed files with 28 additions and 21 deletions

View File

@@ -50,24 +50,14 @@ func subscriptions(model tea.Model) tea.Subs {
m, _ := model.(Model)
if !m.Chosen || m.Loaded {
return tea.Subs{
"tick": tick,
"tick": tea.Every(time.Second, tickMsg{}),
}
}
return tea.Subs{
"frame": frame,
"frame": tea.Every(time.Second/60, frameMsg{}),
}
}
func tick() tea.Msg {
time.Sleep(time.Second)
return tickMsg{}
}
func frame() tea.Msg {
time.Sleep(time.Second / 60)
return frameMsg{}
}
// UPDATES
func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) {