mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-20 14:04:34 -04:00
refactor(tracker): use go v1.23 style iterators throughout
This commit is contained in:
parent
2b7ce39069
commit
97e59c5650
@ -18,7 +18,7 @@ type (
|
||||
}
|
||||
|
||||
AlertPriority int
|
||||
AlertYieldFunc func(alert Alert)
|
||||
AlertYieldFunc func(index int, alert Alert) bool
|
||||
Alerts Model
|
||||
)
|
||||
|
||||
@ -35,9 +35,13 @@ func (m *Model) Alerts() *Alerts { return (*Alerts)(m) }
|
||||
|
||||
// Alerts methods
|
||||
|
||||
func (m *Alerts) Iterate(yield AlertYieldFunc) {
|
||||
for _, a := range m.alerts {
|
||||
yield(a)
|
||||
func (m *Alerts) Iterate() func(yield func(index int, alert Alert) bool) {
|
||||
return func(yield func(index int, alert Alert) bool) {
|
||||
for i, a := range m.alerts {
|
||||
if !yield(i, a) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user