RxCallbacks
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
License
RxCallbacks is available under the MIT license. See the LICENSE file for more info.