杨锴
2025-04-16 09a372bc45fde16fd42257ab6f78b8deeecf720b
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
//
//  KVORepresentable.swift
//  RxCocoa
//
//  Created by Krunoslav Zaher on 11/14/15.
//  Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
 
/// Type that is KVO representable (KVO mechanism can be used to observe it).
public protocol KVORepresentable {
    /// Associated KVO type.
    associatedtype KVOType
 
    /// Constructs `Self` using KVO value.
    init?(KVOValue: KVOType)
}
 
extension KVORepresentable {
    /// Initializes `KVORepresentable` with optional value.
    init?(KVOValue: KVOType?) {
        guard let KVOValue = KVOValue else {
            return nil
        }
 
        self.init(KVOValue: KVOValue)
    }
}