You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ RxHttpClient
8
8
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.
9
9
10
10
##Requirements
11
-
- Xcode 8.1
12
-
- Swift 3.0.1
11
+
- Xcode 8.2
12
+
- Swift 3.0
13
13
14
14
##Installation
15
15
Now only [Carthage](https://github.com/Carthage/Carthage) supported:
16
16
```
17
-
github "ReactiveX/RxSwift" ~> 3.0
17
+
github "ReactiveX/RxSwift" ~> 3.1
18
18
github "Reloni/RxHttpClient"
19
19
```
20
20
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
64
64
let client = HttpClient()
65
65
let bag = DisposeBag()
66
66
let url = URL(string: "url_to_resource")!
67
+
// by default HTTP GET request will be performed
67
68
client.requestData(url: url).subscribe(onNext: { data in /* do something with returned data */ }, onError: { error in
68
69
switch error {
69
70
case HttpClientError.clientSideError(let error): break /* Client-side error */
70
71
case let HttpClientError.invalidResponse(response, data): break /* Occurs when server did't return success HTTP code (not in 2xx) */
71
72
default: break
72
73
}
73
74
}).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)
0 commit comments