summaryrefslogtreecommitdiffhomepage
path: root/ios/Operations/BlockCondition.swift
blob: 79cf14079fc88427e72b277d13c727a4e30d0dce (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
//
//  BlockCondition.swift
//  Operations
//
//  Created by pronebird on 25/09/2022.
//  Copyright © 2022 Mullvad VPN AB. All rights reserved.
//

import Foundation

public final class BlockCondition: OperationCondition {
    public typealias HandlerBlock = (Operation, @escaping (Bool) -> Void) -> Void

    public var name: String {
        "BlockCondition"
    }

    public var isMutuallyExclusive: Bool {
        false
    }

    public let block: HandlerBlock
    public init(block: @escaping HandlerBlock) {
        self.block = block
    }

    public func evaluate(for operation: Operation, completion: @escaping (Bool) -> Void) {
        block(operation, completion)
    }
}