Skip to content

Instantly share code, notes, and snippets.

@lucasecf
Created March 4, 2018 17:45
Show Gist options
  • Save lucasecf/31050dbd4aafa1a66ec62fa134ce55cf to your computer and use it in GitHub Desktop.
Save lucasecf/31050dbd4aafa1a66ec62fa134ce55cf to your computer and use it in GitHub Desktop.
struct HTTPDispatcher: Dispatcher {
 func execute(request: URLRequest, success: (Data) -> Void, failure: (Error) -> Void) {
  // executes HTTP requests using URLSession
  // …
  }
}
struct TestHTTPDispatcher: Dispatcher {
  func execute(request: URLRequest, success: (Data) -> Void, failure: (Error) -> Void) {
 // to be used for unit tests, returns mocked data
  // …
  }
}
struct GraphQLDispatcher: Dispatcher {
  func execute(request: GraphQLQuery, success: (GraphQLQuery.Data) -> Void, error: (Error) -> Void) {
  // Uses graphql lib to load data from server
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment