Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created November 30, 2016 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odrobnik/c7c88c69c88c289e4e0648792bfb66d4 to your computer and use it in GitHub Desktop.
Save odrobnik/c7c88c69c88c289e4e0648792bfb66d4 to your computer and use it in GitHub Desktop.
public enum VanillaRequestError: Error
{
case unexpectedResult(String)
case restfulError(NSError)
}
// the result from a Vanilla API request
public enum VanillaRequestResult<T>
{
case success(T)
case failure(VanillaRequestError)
}
// variant that expects a single T
internal func responseProcessingDataTask<T: JSONInitializable>(_ request: URLRequest, resultsKey: String? = nil, completion: ((VanillaRequestResult<T>)->())?) -> URLSessionDataTask
{
}
// variant that expects an array of T
internal func responseProcessingDataTask<T: JSONInitializable>(_ request: URLRequest, resultsKey: String? = nil, completion: ((VanillaRequestResult<[T]>)->())?) -> URLSessionDataTask
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment