summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Operations/TransformOperation.swift
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-09-14 13:59:01 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-09-15 10:54:31 +0200
commit76dd2c99bf92d608022efbf05ffcbfebda43e0c1 (patch)
tree8cccb074a033089ac531e425f4a825df62b616c3 /ios/MullvadVPN/Operations/TransformOperation.swift
parente553d10b869c46e7ab922b86c32f4bd016e4fdac (diff)
downloadmullvadvpn-76dd2c99bf92d608022efbf05ffcbfebda43e0c1.tar.xz
mullvadvpn-76dd2c99bf92d608022efbf05ffcbfebda43e0c1.zip
Operations: simplify AsyncOperation, remove advanced features
Diffstat (limited to 'ios/MullvadVPN/Operations/TransformOperation.swift')
-rw-r--r--ios/MullvadVPN/Operations/TransformOperation.swift50
1 files changed, 0 insertions, 50 deletions
diff --git a/ios/MullvadVPN/Operations/TransformOperation.swift b/ios/MullvadVPN/Operations/TransformOperation.swift
deleted file mode 100644
index ce2a1617ea..0000000000
--- a/ios/MullvadVPN/Operations/TransformOperation.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// TransformOperation.swift
-// MullvadVPN
-//
-// Created by pronebird on 06/07/2020.
-// Copyright © 2020 Mullvad VPN AB. All rights reserved.
-//
-
-import Foundation
-
-class TransformOperation<Input, Output>: AsyncOperation, InputOperation, OutputOperation {
- private enum Executor {
- case callback((Input, @escaping (Output) -> Void) -> Void)
- case transform((Input) -> Output)
- }
-
- private let executor: Executor
-
- private init(input: Input? = nil, executor: Executor) {
- self.executor = executor
-
- super.init()
- self.input = input
- }
-
- convenience init(input: Input? = nil, _ block: @escaping (Input, @escaping (Output) -> Void) -> Void) {
- self.init(input: input, executor: .callback(block))
- }
-
- convenience init(input: Input? = nil, _ block: @escaping (Input) -> Output) {
- self.init(input: input, executor: .transform(block))
- }
-
- override func main() {
- guard let input = input else {
- self.finish()
- return
- }
-
- switch executor {
- case .callback(let block):
- block(input) { [weak self] (result) in
- self?.finish(with: result)
- }
-
- case .transform(let block):
- self.finish(with: block(input))
- }
- }
-}