mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-17 02:25:12 -07:00
Update examples to use new subscription model
This commit is contained in:
@@ -31,7 +31,7 @@ func main() {
|
||||
initialize,
|
||||
update,
|
||||
view,
|
||||
[]tea.Sub{tick, frame},
|
||||
subscriptions,
|
||||
)
|
||||
if err := p.Start(); err != nil {
|
||||
fmt.Println("could not start program:", err)
|
||||
@@ -46,6 +46,18 @@ func initialize() (tea.Model, tea.Cmd) {
|
||||
|
||||
// SUBSCRIPTIONS
|
||||
|
||||
func subscriptions(model tea.Model) tea.Subs {
|
||||
m, _ := model.(Model)
|
||||
if !m.Chosen || m.Loaded {
|
||||
return tea.Subs{
|
||||
"tick": tick,
|
||||
}
|
||||
}
|
||||
return tea.Subs{
|
||||
"frame": frame,
|
||||
}
|
||||
}
|
||||
|
||||
func tick(model tea.Model) tea.Msg {
|
||||
time.Sleep(time.Second)
|
||||
return tickMsg{}
|
||||
|
||||
Reference in New Issue
Block a user