项目作者: junmo-kim

项目描述 :
Objective-C Bolts wrapper for one time event RxSwift traits
高级语言: Swift
项目地址: git://github.com/junmo-kim/RxToBolts.git
创建时间: 2017-11-05T06:43:59Z
项目社区:https://github.com/junmo-kim/RxToBolts

开源协议:MIT License

下载


RxToBolts

Objective-C Bolts wrapper for RxSwift one time event traits

Build Status

If you want to introduce RxSwift but hesitated from tons of legacy Objective-C classes, this can help.

Get started

  1. In Podfile add this and install

    1. pod 'RxToBolts'
  2. Write your Rx code in Swift

    1. @objc class Service {
    2. func getStatus() -> Single<Status> {
    3. return Single<Status>.create { observer -> Disposable in
    4. [...]
    5. }
    6. }
    7. }
  3. Add wrapper method without any efforts

    1. extension Service {
    2. @objc func objc_getStatus() -> BFTask<Status> {
    3. return getStatus().toBoltsTask()
    4. }
    5. }
  4. Use it on Objective-C
    ```objective-c

  • (void)didTapLoadStatus {
    [[Service objc_getStatus] continueWithBlock:^id(BFTask *task) {
    1. if (task.isCancelled) {
    2. // get status was cancelled.
    3. } else if (task.error) {
    4. // get status failed.
    5. } else {
    6. Status *status = task.result;
    7. NSLog(@"Status: %@", status.text);
    8. }
    9. return nil;
    }];
    }
    ```

:tada: