Latest 0.1.3
Homepage https://github.com/briansemiglia/RxCallbacks
License MIT
Platforms ios 8.0
Dependencies RxSwift
Authors

CI Status
Version
License
Platform

Usage

// Function with single argument of completion handler
let x: Observable<Void> = .fromCallback(PHPhotoLibrary.shared().performChangesAndWait)

// Function with n arguments, the last being a completiong handler
let y: Observable<(Bool, Error?)> = .fromCallback(curry(PHPhotoLibrary.shared().performChanges)({ /* changes */ }))

// Functions that accept completion handlers AND return non-void types aren't compatible
let z: Observable<Void> = .fromCallback(curry(URLSession.shared().dataTask)(URL(string: "")!))

// Because some functions produce multiple callbacks, the Observable returned by `.fromCallback`
// intentionally avoids producing a completion event. To achieve this, the caller may use the 
// `take` operator to produce this event.
let n = Observable<PartialData>.fromCallback(Network.progressiveDownload).take(3)

Example

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

Installation

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

pod 'RxCallbacks'

Author

[email protected]

License

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

Latest podspec

{
    "name": "RxCallbacks",
    "version": "0.1.3",
    "summary": "An RxSwift extension for converting callbacks to observables.",
    "description": "Convert callback closures to observables using the provided static `fromCallback function.",
    "homepage": "https://github.com/briansemiglia/RxCallbacks",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Brian Semiglia": "[email protected]"
    },
    "source": {
        "git": "https://github.com/briansemiglia/RxCallbacks.git",
        "tag": "0.1.3"
    },
    "social_media_url": "https://twitter.com/brians_",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RxCallbacks/Classes/**/*",
    "swift_version": "5.0",
    "dependencies": {
        "RxSwift": [
            "~> 5.0"
        ]
    }
}

Pin It on Pinterest

Share This