RxAlertController is UIAlertController-Extension, which integrates UIAlertController and UIAlertAction into your Rx-Project.
I made this Extension referencing the article below.
RxSwift UIAlertController を observable で表示
- RxSwift
- RxCocoa
- make AlertActions with titles
- make UIAlertController by using static method "showAlert", which returns Observable (index of selected action)
- implement methods of selected actions in subscribe
Example:
let actions = [AlertAction.action(title: ""), AlertAction.action(title: "")]
addButton.rx.tap
.flatMap { UIAlertController.showAlert(from: self, title: "", message: "", style: .alert, actions: actions) }
.subscribe(onNext: { index in
if index == 0 {
print("action1")
} else {
print("action2")
}
})
.disposed(by: disposeBag)