RxAlert 1.1.2

RxAlert 1.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2018
SPMSupports SPM

Maintained by xiaoyaogaojian.



 
Depends on:
RxSwift~> 4.0
RxCocoa~> 4.0
 

RxAlert 1.1.2

  • By
  • xiaoyaogaojian

RxAlert

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

RxSwift

Installation

RxAlert is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'RxAlert'

Usage

  1. Create action to conform AlertActionType protocol

    enum AlertAction: AlertActionType {
    
      case cancel
      case delete
      case ok
    
      var title: String {
        switch self {
        case .cancel:
          return "Cancel"
        case .delete:
          return "Delete"
        case .ok:
          return "OK"
        }
      }
    
      var style: UIAlertActionStyle {
        switch self {
        case .cancel:
          return .cancel
        case .delete:
          return .destructive
        case .ok:
          return .default
        }
      }
    
      // Optional
      var isEnabled: Bool {
        return true
      }
    
    }
  2. Using UIAlertController.rx

    UIAlertController.rx
      .presented(
        by: self,
        title: "Title",
        message: "Some message",
        preferredStyle: .alert,
        actions: [AlertAction.ok, AlertAction.delete, AlertAction.cancel]
      )
      .subscribe(onNext: { action in
        switch action {
        case .ok: print("OK")
        case .delete: print("Delete")
        case .cancel: break
        }
      })
      .disposed(by: disposeBag)

Use demo to get more information.

Author

xiaoyaogaojian, [email protected]

License

RxAlert is available under the MIT license. See the LICENSE file for more info.