Skip to content

Commit 72b6ca0

Browse files
committed
Update readme
1 parent cd67570 commit 72b6ca0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Readme.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ RxHttpClient
88
RxHttpClient is a "reactive wrapper" around NSURLSession. Under the hood it implements session delegates (like NSURLSessionDelegate or NSURLSessionTaskDelegate) and translates session events into Observables using [RxSwift](https://github.com/ReactiveX/RxSwift). Main purpose of this framework is to make "streaming" data as simple as possible and provide convenient features for caching data.
99

1010
##Requirements
11-
- Xcode 8.1
12-
- Swift 3.0.1
11+
- Xcode 8.2
12+
- Swift 3.0
1313

1414
##Installation
1515
Now only [Carthage](https://github.com/Carthage/Carthage) supported:
1616
```
17-
github "ReactiveX/RxSwift" ~> 3.0
17+
github "ReactiveX/RxSwift" ~> 3.1
1818
github "Reloni/RxHttpClient"
1919
```
2020
RxHttpClient uses RxSwift so it should be included into cartfile.
@@ -64,13 +64,23 @@ It's also possible to simply invoke request and receive data using loadData meth
6464
let client = HttpClient()
6565
let bag = DisposeBag()
6666
let url = URL(string: "url_to_resource")!
67+
// by default HTTP GET request will be performed
6768
client.requestData(url: url).subscribe(onNext: { data in /* do something with returned data */ }, onError: { error in
6869
switch error {
6970
case HttpClientError.clientSideError(let error): break /* Client-side error */
7071
case let HttpClientError.invalidResponse(response, data): break /* Occurs when server did't return success HTTP code (not in 2xx) */
7172
default: break
7273
}
7374
}).addDisposableTo(bag)
75+
76+
// use HTTP POST and send data
77+
let sendJson = ["Key1":"Value1", "Key2":"Value2"]
78+
let sendJsonData = try! JSONSerialization.data(withJSONObject: sendJson, options: [])
79+
client.requestData(url: url, method: .post, body: sendJsonData).subscribe(onNext: { data in /* do something with returned data */ }).addDisposableTo(bag)
80+
81+
// or simply pass JSON as parameter
82+
let sendJson = ["Key1":"Value1", "Key2":"Value2"]
83+
client.requestData(url: url, method: .put, jsonBody: sendJson, options: [], httpHeaders: ["Header1": "HeaderVal1"]).subscribe(onNext: { _ in expectation.fulfill() }).addDisposableTo(bag)
7484
```
7585

7686
JSON deserialized object may be requested in same way:

0 commit comments

Comments
 (0)