mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-01-11 22:41:03 +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
|
Time time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type startTick struct{}
|
|
||||||
|
|
||||||
// Update is the Tea update function. This will advance the spinner one frame
|
// 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
|
// every time it's called, regardless the message passed, so be sure the logic
|
||||||
// is setup so as not to call this Update needlessly.
|
// is setup so as not to call this Update needlessly.
|
||||||
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||||
switch msg.(type) {
|
switch msg.(type) {
|
||||||
case startTick:
|
|
||||||
return m, m.tick()
|
|
||||||
case TickMsg:
|
case TickMsg:
|
||||||
m.frame++
|
m.frame++
|
||||||
if m.frame >= len(m.Frames) {
|
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.
|
// Tick is the command used to advance the spinner one frame.
|
||||||
func Tick() tea.Msg {
|
func Tick() tea.Msg {
|
||||||
return startTick{}
|
return TickMsg{Time: time.Now()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Model) tick() tea.Cmd {
|
func (m Model) tick() tea.Cmd {
|
||||||
|
Loading…
Reference in New Issue
Block a user