billp / TermiNetwork

🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.
https://billp.github.io/TermiNetwork
MIT License
99 stars 8 forks source link

Change the way of getting the response #8

Closed billp closed 3 years ago

billp commented 3 years ago

Description

Change the request execution method calls to a simpler approach.

Steps

  1. Split the start() method call to two deifferent methods:
    • response(as:[TYPE], completionHandler([TYPE])
    • error(as:[TYPE], completionHandler([TYPE], [ERROR])
  2. Remove the queue parameter from start() methods and add it as separate method queue([QUEUE])
  3. The transformer calls will be overloaded with the new methods as defined in 1
  4. All the new methods are optional
  5. To start the request without any additional method call for handling responses, implement the exec() function

Example

Router<CityRoute>()
    .request(for: .cities)
    .queue(myQueue)
    .success(transformer: CitiesTransformer.self,
             responseHandler: { model in
    })
    .failure(responseType: MyErrorModel.self,
             responseHandler: { errorModel, error in
    })
create-issue-branch[bot] commented 3 years ago

Branch issue-8-Change_the_way_of_getting_the_response created!