JGProgressHUD-SwiftUI icon indicating copy to clipboard operation
JGProgressHUD-SwiftUI copied to clipboard

Reacting to state changes

Open ravisharmaa opened this issue 2 years ago • 0 comments

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?

ravisharmaa avatar Nov 04 '21 04:11 ravisharmaa