Skip to content

Commit

Permalink
Fix example of URLSession in README
Browse files Browse the repository at this point in the history
  • Loading branch information
raxityo authored and freak4pc committed Oct 28, 2018
1 parent fceb69e commit 038103b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Documentation/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -570,7 +571,7 @@ extension Reactive where Base: URLSession {
return
}

observer.on(.next(data, httpResponse))
observer.on(.next((httpResponse, data)))
observer.on(.completed)
}

Expand Down

0 comments on commit 038103b

Please sign in to comment.