Skip to content

Instance Method

loadingBar(title:targetQueue:)

Creates a new LoadingBar-based ActivityIndicator.
func loadingBar(title: String, targetQueue: DispatchQueue? = nil) -> ActivityIndicator<LoadingBar>

Parameters

title

Title to display alongside the loading bar.

Return Value

An ActivityIndicator that can start and stop the loading bar.

Discussion

Loading [        •             ]

The character will bounce from left to right while the bar is active.

let loadingBar = console.loadingBar(title: "Loading")
background {
    // complete the loading bar after 3 seconds
    console.wait(seconds: 3)
    loadingBar.succeed()
}
// start the loading bar and wait for it to finish
try loadingBar.start(on: ...).wait()