mirror of
https://github.com/Maks1mS/bubbles.git
synced 2024-12-24 14:44:38 +03:00
Remove internal msg in spinner so all tick msgs can be caught externally
This commit is contained in:
parent
84f7b047bb
commit
9c38e101d2
@ -148,15 +148,11 @@ type TickMsg struct {
|
||||
Time time.Time
|
||||
}
|
||||
|
||||
type startTick struct{}
|
||||
|
||||
// Update is the Tea update function. This will advance the spinner one frame
|
||||
// every time it's called, regardless the message passed, so be sure the logic
|
||||
// is setup so as not to call this Update needlessly.
|
||||
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
switch msg.(type) {
|
||||
case startTick:
|
||||
return m, m.tick()
|
||||
case TickMsg:
|
||||
m.frame++
|
||||
if m.frame >= len(m.Frames) {
|
||||
@ -189,7 +185,7 @@ func (m Model) View() string {
|
||||
|
||||
// Tick is the command used to advance the spinner one frame.
|
||||
func Tick() tea.Msg {
|
||||
return startTick{}
|
||||
return TickMsg{Time: time.Now()}
|
||||
}
|
||||
|
||||
func (m Model) tick() tea.Cmd {
|
||||
|
Loading…
Reference in New Issue
Block a user