Latest 1.1.2
Homepage https://github.com/xiaoyaogaojian/RxAlert
License MIT
Platforms ios 8.0
Dependencies RxSwift, RxCocoa
Frameworks UIKit
Authors

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.

Latest podspec

{
    "name": "RxAlert",
    "version": "1.1.2",
    "summary": "A RxSwift extension for UIAlertController",
    "description": "A RxSwift extension for UIAlertController.",
    "homepage": "https://github.com/xiaoyaogaojian/RxAlert",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "xiaoyaogaojian": "[email protected]"
    },
    "source": {
        "git": "https://github.com/xiaoyaogaojian/RxAlert.git",
        "tag": "1.1.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RxAlert/Classes/**/*",
    "frameworks": "UIKit",
    "dependencies": {
        "RxSwift": [
            "~> 4.0"
        ],
        "RxCocoa": [
            "~> 4.0"
        ]
    }
}

Pin It on Pinterest

Share This