Skip to content

Commit db18fdc

Browse files
committed
Removed unneeded 'finish' method from 'cancel' method
1 parent ca88890 commit db18fdc

5 files changed

Lines changed: 7 additions & 15 deletions

File tree

NetworkingInOperations-Example/Data/Abstract/ConcurrentOperation.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import Foundation
1010
import UIKit
1111

12-
enum DataRequestResult<T> {
12+
enum Result<T> {
1313
case success(T)
1414
case failure(Error)
1515
}
1616

1717
class ConcurrentOperation<T>: Operation {
1818

19-
typealias OperationCompletionHandler = (_ result: DataRequestResult<T>) -> Void
19+
typealias OperationCompletionHandler = (_ result: Result<T>) -> Void
2020

2121
var completionHandler: (OperationCompletionHandler)?
2222

@@ -51,12 +51,6 @@ class ConcurrentOperation<T>: Operation {
5151
return state == .finished
5252
}
5353

54-
// MARK: - Asynchronous
55-
56-
override var isAsynchronous: Bool {
57-
return true
58-
}
59-
6054
// MARK: - Start
6155

6256
override func start() {
@@ -80,7 +74,7 @@ class ConcurrentOperation<T>: Operation {
8074
}
8175
}
8276

83-
func complete(result: DataRequestResult<T>) {
77+
func complete(result: Result<T>) {
8478
finish()
8579

8680
if !isCancelled {

NetworkingInOperations-Example/Data/Managers/Questions/Operations/QuestionsRetrievalOperation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ class QuestionsRetrievalOperation: ConcurrentOperation<QuestionPage> {
6060
// MARK: - Cancel
6161

6262
override func cancel() {
63-
super.cancel()
6463
task?.cancel()
65-
finish()
64+
super.cancel()
6665
}
6766
}

NetworkingInOperations-Example/Data/Managers/Questions/QuestionsDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class QuestionsDataManager {
2020

2121
// MARK: - Retrieval
2222

23-
func retrievalQuestions(pageIndex: Int, completionHandler: @escaping (_ result: DataRequestResult<QuestionPage>) -> Void) {
23+
func retrievalQuestions(pageIndex: Int, completionHandler: @escaping (_ result: Result<QuestionPage>) -> Void) {
2424
let operation = QuestionsRetrievalOperation(pageIndex: pageIndex)
2525
operation.completionHandler = completionHandler
2626
queueManager.enqueue(operation)

NetworkingInOperations-Example/Data/Managers/User/Operations/AvatarRetrievalOperation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ class AvatarRetrievalOperation: ConcurrentOperation<(User, UIImage)> {
5555
// MARK: - Cancel
5656

5757
override func cancel() {
58-
super.cancel()
5958
task?.cancel()
60-
finish()
59+
super.cancel()
6160
}
6261
}

NetworkingInOperations-Example/Data/Managers/User/UserDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class UserDataManager {
2121

2222
// MARK: - Avatar
2323

24-
func retrieveAvatar(forUser user: User, completionHandler: @escaping (_ result: DataRequestResult<(User, UIImage)>) -> Void) {
24+
func retrieveAvatar(forUser user: User, completionHandler: @escaping (_ result: Result<(User, UIImage)>) -> Void) {
2525
let operation = AvatarRetrievalOperation(user: user)
2626
operation.completionHandler = completionHandler
2727
queueManager.enqueue(operation)

0 commit comments

Comments
 (0)