关键词:
func test() -> Observable<Any>
return Observable.create( (observer) -> Disposable in
// requestJSON
RxAlamofire.requestData(self.method, self.url, parameters: self.parameters, encoding: self.encoding, headers: self.headers)
.subscribe( event in
switch event
case .next(let responce, let data):
do
//Do THis hahahaha
observer.onNext(self.parse(dsd: MinimalUser.self, data: data))
catch let e as RESTError
observer.onError(e)
catch
observer.onError(error)
case .error(let error):
observer.onError(self.handleError(error: error))
case .completed:
observer.onCompleted()
)
)
func parse<T: Codable>(dsd:T.Type,data: Data) -> T
let jsonDecoder = JSONDecoder()
return try! jsonDecoder.decode(dsd.self, from: data)
public struct MinimalUser: Codable
public let id: Int
public let login: String
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情
textgistfile1.txt(代码片段)
查看详情