Skip to content

Instantly share code, notes, and snippets.

@zzdjk6
Created July 17, 2016 16:37
Show Gist options
  • Save zzdjk6/755e2fedf52fb3db9aead6a502bf7324 to your computer and use it in GitHub Desktop.
Save zzdjk6/755e2fedf52fb3db9aead6a502bf7324 to your computer and use it in GitHub Desktop.
Convenient way to show MBProgressHUD while RxSwift signal executing
extension ObservableType {
func showHUDWhileExecuting(view: UIView) -> RxSwift.Observable<Self.E> {
dispatch_async(dispatch_get_main_queue()) {
MBProgressHUD.showHUDAddedTo(view, animated: true)
}
return self.doOn { (_) in
dispatch_async(dispatch_get_main_queue()) {
MBProgressHUD.hideAllHUDsForView(view, animated: true)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment