Skip to content

Commit 63e2b00

Browse files
committed
refactoring: BarParkTo
1 parent de760b5 commit 63e2b00

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

_examples/complex/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
job := "installing"
4949
// preparing delayed bars
5050
b := p.AddBar(rand.Int63n(101)+100,
51-
mpb.BarReplaceOnComplete(bars[i]),
51+
mpb.BarParkTo(bars[i]),
5252
mpb.BarClearOnComplete(),
5353
mpb.PrependDecorators(
5454
decor.Name(task, decor.WC{W: len(task) + 1, C: decor.DidentRight}),

bar_option.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ func BarRemoveOnComplete() BarOption {
6161
}
6262
}
6363

64-
// BarReplaceOnComplete is indicator for delayed bar start, after the
65-
// `runningBar` is complete. To achieve bar replacement effect,
66-
// `runningBar` should has its `BarRemoveOnComplete` option set.
64+
// BarReplaceOnComplete is deprecated. Refer to BarParkTo option.
6765
func BarReplaceOnComplete(runningBar *Bar) BarOption {
66+
return BarParkTo(runningBar)
67+
}
68+
69+
// BarParkTo parks constructed bar into the runningBar. In other words,
70+
// constructed bar will start only after runningBar has been completed.
71+
// Parked bar will replace runningBar if BarRemoveOnComplete option
72+
// is set on the runningBar. Parked bar inherits priority of the
73+
// runningBar, if no BarPriority option is set.
74+
func BarParkTo(runningBar *Bar) BarOption {
6875
return func(s *bState) {
6976
s.runningBar = runningBar
7077
}

0 commit comments

Comments
 (0)