Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junmo-kim/rxtobolts
Objective-C Bolts wrapper for one time event RxSwift traits
https://github.com/junmo-kim/rxtobolts
bolts objective-c rxswift swift
Last synced: 3 days ago
JSON representation
Objective-C Bolts wrapper for one time event RxSwift traits
- Host: GitHub
- URL: https://github.com/junmo-kim/rxtobolts
- Owner: junmo-kim
- License: mit
- Created: 2017-11-05T06:43:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-05T13:24:16.000Z (over 6 years ago)
- Last Synced: 2024-09-30T15:18:42.661Z (3 days ago)
- Topics: bolts, objective-c, rxswift, swift
- Language: Swift
- Size: 19.5 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RxToBolts
Objective-C [Bolts](https://github.com/BoltsFramework/Bolts-ObjC) wrapper for [RxSwift](https://github.com/ReactiveX/RxSwift) one time event traits
[![Build Status](https://travis-ci.org/junmo-kim/RxToBolts.svg?branch=master)](https://travis-ci.org/junmo-kim/RxToBolts)
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
```
pod 'RxToBolts'
```2. Write your Rx code in Swift
```swift
@objc class Service {
func getStatus() -> Single {
return Single.create { observer -> Disposable in
[...]
}
}
}
```3. Add wrapper method without any efforts
```swift
extension Service {
@objc func objc_getStatus() -> BFTask {
return getStatus().toBoltsTask()
}
}
```4. Use it on Objective-C
```objective-c
- (void)didTapLoadStatus {
[[Service objc_getStatus] continueWithBlock:^id(BFTask *task) {
if (task.isCancelled) {
// get status was cancelled.
} else if (task.error) {
// get status failed.
} else {
Status *status = task.result;
NSLog(@"Status: %@", status.text);
}
return nil;
}];
}
```:tada: