summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Operations/AsyncBlockOperation.swift
blob: c8f4287b32b3b322783206939a3d94d9e9daa625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
//  AsyncBlockOperation.swift
//  MullvadVPN
//
//  Created by pronebird on 06/07/2020.
//  Copyright © 2020 Mullvad VPN AB. All rights reserved.
//

import Foundation

/// Asynchronous block operation
class AsyncBlockOperation: AsyncOperation {
    private let block: (@escaping () -> Void) -> Void

    init(_ block: @escaping (@escaping () -> Void) -> Void) {
        self.block = block
        super.init()
    }

    override func main() {
        self.block { [weak self] in
            self?.finish()
        }
    }
}