JGProgressHUD-SwiftUI
JGProgressHUD-SwiftUI copied to clipboard
Reacting to state changes
As I see the current state of art, I need to do dismiss(afterDelay: )
with the hud. What about dismissing it with when there is a change in a property of a view model. Let's say I want to hide after fetching is completed. I am doing it this way, I don't know whether it is a good approach or not.
hudCoordinator.showHUD {
let hud = JGProgressHUD()
hud.textLabel.text = "Fetching Profile Details....."
hud.textLabel.font = UIFont(name: FontConstants.poppinsMedium, size: 12)
hud.backgroundColor = UIColor(white: 0, alpha: 0.4)
viewModel.$fetchedCompleted.sink { completed in
if completed {
hud.dismiss()
}
}.store(in: &viewModel.subscription)
return hud
}
Can anybody guide me with this?