Hello Mr Balog. I’m using your Vox library , I have a question . I use it in whole of my project , I write repeating code every time and it’s not ok. Look at this attached swift file , this is my function that every time I use. Is there any way to write it once and call it every where I need and just change resource and method every time not to write all function , because I am doing same in on failure block every time .
I’ll be really happy if you help me dear Aron Balog .
let client = JSONAPIClient.Alamofire(baseURL: baseURL)
let dataSource = DataSource<resourse>(strategy: .path("/path"), client: client)
do{
try dataSource
.fetch().include(["something"])
.result({ (document: Document<[resourse]>) in
let results = document.data
// do some thing
}) { (error) in
// and do this every time
if let error = error as? JSONAPIError {
switch error {
case .API( let errors):
ApiResponse(response: errors)
default:()
}
return
}else{
ApiResponse(response: nil)
}
}
}catch let error_object{
print(error_object)
}
Hello Mr Balog. I’m using your Vox library , I have a question . I use it in whole of my project , I write repeating code every time and it’s not ok. Look at this attached swift file , this is my function that every time I use. Is there any way to write it once and call it every where I need and just change resource and method every time not to write all function , because I am doing same in on failure block every time . I’ll be really happy if you help me dear Aron Balog .