UpdateWhere is the type-safe free-function version.
(s *StateValue[[]T], pred func(T) bool, mut func(T) T)
| 145 | |
| 146 | // UpdateWhere is the type-safe free-function version. |
| 147 | func UpdateWhere[T any](s *StateValue[[]T], pred func(T) bool, mut func(T) T) { |
| 148 | s.mu.Lock() |
| 149 | for i, el := range s.value { |
| 150 | if pred(el) { |
| 151 | s.value[i] = mut(el) |
| 152 | } |
| 153 | } |
| 154 | v := s.value |
| 155 | s.mu.Unlock() |
| 156 | |
| 157 | s.notifyInternal(v) |
| 158 | if s.onStateChange != nil { |
| 159 | s.onStateChange() |
| 160 | } |
| 161 | } |
nothing calls this directly
no test coverage detected