Skip to content

Commit

Permalink
Use model-based Tick commands in spinner examples
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Jan 13, 2022
1 parent ee92bed commit 2d82777
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/spinner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func initialModel() model {
}

func (m model) Init() tea.Cmd {
return spinner.Tick
return m.spinner.Tick
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
Expand Down
6 changes: 3 additions & 3 deletions examples/spinners/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type model struct {
}

func (m model) Init() tea.Cmd {
return spinner.Tick
return m.spinner.Tick
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
Expand All @@ -59,14 +59,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.index = len(spinners) - 1
}
m.resetSpinner()
return m, spinner.Tick
return m, m.spinner.Tick
case "l", "right":
m.index++
if m.index >= len(spinners) {
m.index = 0
}
m.resetSpinner()
return m, spinner.Tick
return m, m.spinner.Tick
default:
return m, nil
}
Expand Down

0 comments on commit 2d82777

Please sign in to comment.