summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Operations/AlertPresenter.swift
blob: 7c31017a4e4b5a25976d7352eab45e6f1f8bb792 (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
27
28
29
30
31
32
//
//  AlertPresenter.swift
//  MullvadVPN
//
//  Created by pronebird on 04/06/2020.
//  Copyright © 2020 Mullvad VPN AB. All rights reserved.
//

import Operations
import UIKit

final class AlertPresenter {
    private let operationQueue = AsyncOperationQueue.makeSerial()

    func enqueue(
        _ alertController: CustomAlertViewController,
        presentingController: UIViewController,
        presentCompletion: (() -> Void)? = nil
    ) {
        let operation = PresentAlertOperation(
            alertController: alertController,
            presentingController: presentingController,
            presentCompletion: presentCompletion
        )

        operationQueue.addOperation(operation)
    }

    func cancelAll() {
        operationQueue.cancelAllOperations()
    }
}