Skip to content

Instantly share code, notes, and snippets.

@nalexn
Created September 29, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nalexn/3c6fb6f64b46c9cd1aa30dbd9033ac9c to your computer and use it in GitHub Desktop.
Save nalexn/3c6fb6f64b46c9cd1aa30dbd9033ac9c to your computer and use it in GitHub Desktop.
struct HomeView: View {
let viewModel: HomeViewModel
@State var isLoadingData = false
var body: some View {
if isLoadingData {
ProgressView()
}
Button("Do something!") {
self.viewModel.doSomething()
}
.onReceive(viewModel.isLoadingData.publisher) {
self.isLoadingData = $0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment