Skip to content

Show loading while doing .configure work #2195

Answered by calda
Bjorninn1 asked this question in Q&A
Discussion options

You must be logged in to vote

.configure is called on every SwiftUI state update so shouldn't be used for anything stateful like this. What are you trying to do exactly?

One way to show a loading indicator is using this init syntax:

LottieView {
  LottieAnimation.named(imageName)
} placeholder: {
  // Displayed until the animation is loaded
  MyLoadingIndicator()
}

Alternatively you could do something like:

LottieView(animation: LottieAnimation.named(imageName))
  .animationDidLoad {
    // The animation has now finished loading. Called exactly once.
  }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Bjorninn1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants