Skip to content

Instantly share code, notes, and snippets.

@bobgodwinx
Created June 27, 2018 05:53
Show Gist options
  • Save bobgodwinx/4e6812c23532a08692f769b1293500f9 to your computer and use it in GitHub Desktop.
Save bobgodwinx/4e6812c23532a08692f769b1293500f9 to your computer and use it in GitHub Desktop.
OST03
class RxMBProgressHUD: ObserverType {
static let shared = RxMBProgressHUD()
enum State {
case hide(view: UIView?, animated: Bool)
case show(view: UIView?, animated: Bool)
}
typealias E = RxMBProgressHUD.State
func on(_ event: Event<State>) {
guard case .next(let state) = event else { return }
switch state {
case .hide(let view, let animated):
guard let view = view else { return }
MBProgressHUD.hide(for: view, animated: animated)
case .show(let view, let animated):
guard let view = view else { return }
MBProgressHUD.showAdded(to:view, animated: animated)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment