mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-03-14 04:53:43 +03:00
Update subs for Tea v0.2.1. That is to say, remove the their arguments.
This commit is contained in:
parent
6c2e144255
commit
da64445a0e
@ -154,14 +154,24 @@ func updateInputs(msg tea.Msg, m Model) Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func subscriptions(model tea.Model) tea.Subs {
|
func subscriptions(model tea.Model) tea.Subs {
|
||||||
|
m, ok := model.(Model)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a little hacky, but we're using the subscription from one
|
||||||
|
// input element to handle the blinking for all elements. It doesn't
|
||||||
|
// have to be this way, we're just feeling a bit lazy at the moment.
|
||||||
|
inputSub, err := input.MakeSub(m.nameInput)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return tea.Subs{
|
return tea.Subs{
|
||||||
// It's a little hacky, but we're using the subscription from one
|
// It's a little hacky, but we're using the subscription from one
|
||||||
// input element to handle the blinking for all elements. It doesn't
|
// input element to handle the blinking for all elements. It doesn't
|
||||||
// have to be this way, we're just feeling a bit lazy at the moment.
|
// have to be this way, we're just feeling a bit lazy at the moment.
|
||||||
"blink": func(model tea.Model) tea.Msg {
|
"blink": inputSub,
|
||||||
m, _ := model.(Model)
|
|
||||||
return input.Blink(m.nameInput)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +86,16 @@ func View(model Model) string {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sub is the subscription that allows the spinner to spin
|
// GetSub creates the subscription that allows the spinner to spin. Remember
|
||||||
func Sub(model tea.Model) tea.Msg {
|
// that you need to execute this function in order to get the subscription
|
||||||
|
// you'll need.
|
||||||
|
func MakeSub(model tea.Model) (tea.Sub, error) {
|
||||||
m, ok := model.(Model)
|
m, ok := model.(Model)
|
||||||
if !ok {
|
if !ok {
|
||||||
return assertionErr
|
return nil, assertionErr
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second / time.Duration(m.FPS))
|
return func() tea.Msg {
|
||||||
return TickMsg{}
|
time.Sleep(time.Second / time.Duration(m.FPS))
|
||||||
|
return TickMsg{}
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -230,13 +230,15 @@ func cursorView(s string, m Model) string {
|
|||||||
String()
|
String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blink is the subscription that lets us know when to alternate the blinking
|
// MakeSub return a subscription that lets us know when to alternate the
|
||||||
// of the cursor.
|
// blinking of the cursor.
|
||||||
func Blink(model tea.Model) tea.Msg {
|
func MakeSub(model tea.Model) (tea.Sub, error) {
|
||||||
m, ok := model.(Model)
|
m, ok := model.(Model)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrMsg(errors.New("could not assert given model to the model we expected; make sure you're passing as input model"))
|
return nil, errors.New("could not assert given model to the model we expected; make sure you're passing as input model")
|
||||||
}
|
}
|
||||||
time.Sleep(m.BlinkSpeed)
|
return func() tea.Msg {
|
||||||
return CursorBlinkMsg{}
|
time.Sleep(m.BlinkSpeed)
|
||||||
|
return CursorBlinkMsg{}
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user