From 038103b4e8526fb00f8ab26496fad8560ebce965 Mon Sep 17 00:00:00 2001 From: Raxit Majithiya Date: Sun, 28 Oct 2018 04:10:52 -0700 Subject: [PATCH] Fix example of `URLSession` in README --- Documentation/GettingStarted.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/GettingStarted.md b/Documentation/GettingStarted.md index 3f4402641..96e8c1540 100644 --- a/Documentation/GettingStarted.md +++ b/Documentation/GettingStarted.md @@ -557,11 +557,12 @@ This is how HTTP requests are wrapped in Rx. It's pretty much the same pattern l ```swift extension Reactive where Base: URLSession { - public func response(_ request: URLRequest) -> Observable<(Data, HTTPURLResponse)> { + public func response(request: URLRequest) -> Observable<(response: HTTPURLResponse, data: Data)> { return Observable.create { observer in - let task = self.dataTaskWithRequest(request) { (data, response, error) in + let task = self.base.dataTask(with: request) { (data, response, error) in + guard let response = response, let data = data else { - observer.on(.error(error ?? RxCocoaURLError.Unknown)) + observer.on(.error(error ?? RxCocoaURLError.unknown)) return } @@ -570,7 +571,7 @@ extension Reactive where Base: URLSession { return } - observer.on(.next(data, httpResponse)) + observer.on(.next((httpResponse, data))) observer.on(.completed) }