@@ -34,34 +34,34 @@ Example:
3434
3535let caller = RequestCaller (config : URLSessionConfiguration.default )
3636
37- func fetchUser (byUserId userId) throws -> Observable<Result<User, ErrorModel>> {
37+ func fetchUser (byUserId userId) -> Observable<Result<User, ErrorModel>> {
3838 let request:URLRequest = RequestModel (
3939 httpMethod : .get ,
4040 path : " v1/users/\( userId ) " )
4141 .asURLRequest ()
42- return try caller.call (request)
42+ return caller.call (request)
4343 }
4444```
4545
4646** Let say it’s an array of users; since Array conforms to Codable, all you have to do is specify the type to be ` [User] ` .**
4747
4848Example:
4949``` Swift
50- func fetchUsers () throws -> Observable<Result<[User], ErrorModel>> {
50+ func fetchUsers () -> Observable<Result<[User], ErrorModel>> {
5151 let request:URLRequest = RequestModel (
5252 httpMethod : .get ,
5353 path : " v1/users" )
5454 .asURLRequest ()
55- return try caller.call (request)
55+ return caller.call (request)
5656 }
5757```
5858
5959About handling ResponseError:
6060
61- ** RxRetroSwift** provided a typealias ** ErrorCodable** which is a combination of [ HasErrorCode ] ( Sources/Protocols/HasErrorCode .swift ) and [ Decodable] ( https://developer.apple.com/documentation/swift/decodable ) protocol:
61+ ** RxRetroSwift** provided a typealias ** ErrorCodable** which is a combination of [ HasErrorInfo ] ( Sources/Protocols/HasErrorInfo .swift ) and [ Decodable] ( https://developer.apple.com/documentation/swift/decodable ) protocol:
6262
6363``` Swift
64- public typealias CodableError = Decodable & HasErrorCode
64+ public typealias DecodableError = Decodable & HasErrorInfo
6565```
6666
6767For example, the json error response of your login request is
@@ -91,7 +91,7 @@ How about dealing to a request that don't expect to return an object or model?
9191
9292``` swift
9393
94- public func call <DecodableErrorModel :DecodableError >(_ request : URLRequest) throws
94+ public func call <DecodableErrorModel :DecodableError >(_ request : URLRequest)
9595 -> Observable< Result< RawResponse, DecodableErrorModel>>
9696```
9797
@@ -162,69 +162,69 @@ class APIClient {
162162 RequestModel.defaults .baseUrl = " https://jsonplaceholder.typicode.com"
163163 }
164164
165- func fetchPosts () throws -> Observable<Result<[Post], ErrorModel>> {
165+ func fetchPosts () -> Observable<Result<[Post], ErrorModel>> {
166166 let request = RequestModel (
167167 httpMethod : .get ,
168168 path : " posts" )
169169 .asURLRequest ()
170170
171- return try caller.call (request)
171+ return caller.call (request)
172172 }
173173
174- func insertPost (post :Post) throws -> Observable<Result<Post, ErrorModel>> {
174+ func insertPost (post :Post) -> Observable<Result<Post, ErrorModel>> {
175175 let request = RequestModel (
176176 httpMethod : .post ,
177177 path : " posts" ,
178178 payload : post.dictionaryValue )
179179 .asURLRequest ()
180180
181- return try caller.call (request)
181+ return caller.call (request)
182182 }
183183
184- func fetchComments () throws -> Observable<Result<[Comment], ErrorModel>> {
184+ func fetchComments () -> Observable<Result<[Comment], ErrorModel>> {
185185 let request = RequestModel (
186186 httpMethod : .get ,
187187 path : " comments" )
188188 .asURLRequest ()
189189
190- return try caller.call (request)
190+ return caller.call (request)
191191 }
192192
193- func fetchAlbums () throws -> Observable<Result<[Album], ErrorModel>> {
193+ func fetchAlbums () -> Observable<Result<[Album], ErrorModel>> {
194194 let request = RequestModel (
195195 httpMethod : .get ,
196196 path : " albums" )
197197 .asURLRequest ()
198198
199- return try caller.call (request)
199+ return caller.call (request)
200200 }
201201
202- func fetchPhotos () throws -> Observable<Result<[Photo], ErrorModel>> {
202+ func fetchPhotos () -> Observable<Result<[Photo], ErrorModel>> {
203203 let request = RequestModel (
204204 httpMethod : .get ,
205205 path : " photos" )
206206 .asURLRequest ()
207207
208- return try caller.call (request)
208+ return caller.call (request)
209209 }
210210
211- func fetchTodos () throws -> Observable<Result<[Todo], ErrorModel>> {
211+ func fetchTodos () -> Observable<Result<[Todo], ErrorModel>> {
212212 let request = RequestModel (
213213 httpMethod : .get ,
214214 path : " todos" )
215215 .asURLRequest ()
216216
217- return try caller.call (request)
217+ return caller.call (request)
218218 }
219219
220- func fetchUsers () throws -> Observable<Result<[User],ErrorModel>> {
220+ func fetchUsers () -> Observable<Result<[User],ErrorModel>> {
221221
222222 let request = RequestModel (
223223 httpMethod : .get ,
224224 path : " users" )
225225 .asURLRequest ()
226226
227- return try caller.call (request)
227+ return caller.call (request)
228228 }
229229}
230230```
@@ -305,3 +305,7 @@ Michael Henry Pantaleon, me@iamkel.net
305305## License
306306
307307RxRetroSwift is available under the MIT license. See the LICENSE file for more info.
308+
309+
310+
311+
0 commit comments