Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (23 sloc) 717 Bytes
import Foundation
import RxSwift
import APIKit
extension Session: ReactiveCompatible {
}
extension Reactive where Base: Session {
func response<T: Request>(_ request: T) -> Observable<T.Response> {
return Observable.create { [weak base] observer in
let task = base?.send(request) { result in
switch result {
case .success(let response):
observer.on(.next(response))
observer.on(.completed)
case .failure(let error):
observer.onError(error)
}
}
return Disposables.create {
task?.cancel()
}
}
}
}
You can’t perform that action at this time.