RxCallbacks 0.1.3

RxCallbacks 0.1.3

Brian Semiglia 维护。



RxCallbacks

CI Status Version License Platform

用法

// 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)

示例

要运行示例项目,请先从仓库克隆,然后在示例目录中首先运行 pod install

安装

RxCallbacks 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:

pod 'RxCallbacks'

作者

[email protected]

许可协议

RxCallbacks是在MIT协议下可用的。有关更多信息,请参阅LICENSE文件。