Skip to content

Commit

Permalink
Move NetworkResultCallback inside the class
Browse files Browse the repository at this point in the history
This makes it more consistent
  • Loading branch information
jkmassel committed Mar 25, 2020
1 parent fac0f65 commit b3ce8fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Foundation

typealias NetworkResultCallback = (Result<Data?, Error>) -> Void

open class EventLoggingNetworkService {

typealias ResultCallback = (Result<Data?, Error>) -> Void

private let urlSession: URLSession

init(urlSession: URLSession = URLSession.shared) {
self.urlSession = urlSession
}

func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping NetworkResultCallback) {
func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping ResultCallback) {
urlSession.uploadTask(with: request, fromFile: fileURL, completionHandler: { data, response, error in

if let error = error {
Expand Down
2 changes: 1 addition & 1 deletion Automattic-Tracks-iOSTests/Test Helpers/Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class MockEventLoggingDelegate: EventLoggingDelegate {
class MockEventLoggingNetworkService: EventLoggingNetworkService {
var shouldSucceed = true

override func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping NetworkResultCallback) {
override func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping EventLoggingNetworkService.ResultCallback) {
shouldSucceed ? completion(.success(Data())) : completion(.failure(MockError.generic))
}
}
Expand Down

0 comments on commit b3ce8fe

Please sign in to comment.