Latest1.0
Homepagehttps://github.com/SideEffects-xyz/RxBrightFutures
LicenseMIT
Platformsios 8.0, osx 10.10, requires ARC
DependenciesBrightFutures, RxSwift
Authors

RxBrightFutures is a tiny wrapper around BrightFutures that allows transforming promises and futures into observables or subjects using a single function rx_observable or rx_subject.

Example

There’s a project as example in the repository, but the basic is shown in the following snipped:

let stringURL = "..."        
let url = NSURL(string: stringURL)!
let request = NSURLRequest(URL: url)
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config)

let networkPromise = Promise<NSData, NSError>()

let task : NSURLSessionDataTask = session.dataTaskWithRequest(request) { (data, response, error) in

    if let e = error {
        networkPromise.tryFailure(e)
    } else {
        if let d = data {
            networkPromise.trySuccess(d)
        } else {
            networkPromise.tryFailure(NSError(domain: "Data error", code: -1, userInfo: nil))
        }
    }

}

networkPromise.future
    .flatMap() { value in
        return self.deserializeData(value)
    }
    .rx_observable()
    .subscribeNext() { json in
        self.toTextField.text = self.processData(json)
    }

task.resume()

Contributions

Contributions are welcomed in the develop repository. Any pull-request to the master branch will be rejected.

LICENSE

This project is released under MIT License.

Latest podspec

{
    "name": "RxBrightFutures",
    "version": "1.0",
    "license": "MIT",
    "summary": "RxSwift wrapper around the Future/Promise library BrightFutures",
    "homepage": "https://github.com/SideEffects-xyz/RxBrightFutures",
    "authors": {
        "Junior B.": "[email protected]"
    },
    "source": {
        "git": "https://github.com/SideEffects-xyz/RxBrightFutures.git",
        "tag": "1.0"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "source_files": "Source/*.swift",
    "requires_arc": true,
    "dependencies": {
        "BrightFutures": [
            "~> 5.1"
        ],
        "RxSwift": [
            "~> 3.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This