EnableTriggerComplete only after total has been set
Vladimir Bauer
4 years ago
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // EnableTriggerComplete enables triggering complete event. It's |
| 159 | // effective only for bar which was constructed with `total <= 0`. | |
| 160 | // If bar has been incremented to the total, complete event is | |
| 161 | // triggered right away. | |
| 159 | // effective only for bar which was constructed with `total <= 0` and | |
| 160 | // after total has been set with (*Bar).SetTotal(int64, false). If bar | |
| 161 | // has been incremented to the total, complete event is triggered right | |
| 162 | // away. | |
| 162 | 163 | func (b *Bar) EnableTriggerComplete() { |
| 163 | 164 | select { |
| 164 | 165 | case b.operateState <- func(s *bState) { |
| 165 | if s.triggerComplete { | |
| 166 | if s.triggerComplete || s.total <= 0 { | |
| 166 | 167 | return |
| 167 | 168 | } |
| 168 | 169 | if s.current >= s.total { |