removed requirement for Show() method call

This commit is contained in:
milarin 2023-03-10 22:22:56 +01:00
parent acfe7532d1
commit 5cb77ec486

10
view.go
View File

@ -40,10 +40,7 @@ func NewForWriter[K comparable](w io.Writer) *View[K] {
}
func (v *View[K]) Show() {
go func() {
defer close(v.reportCh)
v.wg.Wait()
}()
go v.WaitForAllTasks()
for status := range v.reportCh {
v.lastReports[status.ID] = status
@ -83,5 +80,10 @@ func (v *View[K]) Done(task K) {
}
func (v *View[K]) WaitForAllTasks() {
go func() {
defer close(v.reportCh)
v.wg.Wait()
}()
<-v.doneCh
}