daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Foundation
  2. import APIKit
  3. import RxSwift
  4.  
  5. extension Session: ReactiveCompatible {}
  6. extension Reactive where Base: Session {
  7.     static func send<T: Request>(request: T) -> Observable<T.Response> {
  8.         return Observable.create { observer in
  9.             let task = Session.shared.send(request) { result in
  10.                 switch result {
  11.                 case .success(let response): observer.on(.next(response))
  12.                                              observer.on(.completed)
  13.                 case .failure(let error): observer.onError(error)
  14.                 }
  15.             }
  16.             return Disposables.create { task?.cancel() }
  17.         }
  18.     }
  19. }
RAW Paste Data
Top