import UIKit
import RxSwift
import RxCocoa
import SVProgressHUD
final class ViewController: UIViewController {
@IBOutlet weak private var button: UIButton!
private var isShowIndicator = false
private let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
bind()
}
private func bind() {
button.rx.tap
.asSignal()
.emit(onNext: { _ in
self.isShowIndicator.toggle()
self.rx.indicatior.onNext(self.isShowIndicator)
})
.disposed(by: disposeBag)
}
}
extension Reactive where Base: UIViewController {
var indicatior: Binder<Bool> {
return Binder(self.base) { (_, value: Bool) in
value ? SVProgressHUD.show() : SVProgressHUD.dismiss()
}
}
}
Created
April 28, 2019 04:55
-
-
Save KentarouKanno/42c547d4bf8680bbf533a110f52d0e51 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment