Skip to content

Instance Method

loadingBar(title:)

Creates a new LoadingBar-based ActivityIndicator.
func loadingBar(title: String) -> 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")
try await loadingBar.withActivityIndicator {
   try await Task.sleep(for: .seconds(3))
}