mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Add 'Every' subscription for ticking with the system clock
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user