summaryrefslogtreecommitdiffhomepage
path: root/ios/Operations/BlockCondition.swift
blob: e5739a2d16a594e382f46d8f0262ec676d1b2915 (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 © 2025 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)
    }
}