36 lines
619 B
Swift
36 lines
619 B
Swift
//
|
|
// KVORepresentable.swift
|
|
// Rx
|
|
//
|
|
// Created by Krunoslav Zaher on 11/14/15.
|
|
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/**
|
|
Type that is KVO representable (KVO mechanism can be used to observe it).
|
|
*/
|
|
public protocol KVORepresentable {
|
|
/**
|
|
Associated KVO type.
|
|
*/
|
|
typealias KVOType
|
|
|
|
/**
|
|
Constructs `Self` using KVO value.
|
|
*/
|
|
init?(KVOValue: KVOType)
|
|
}
|
|
|
|
extension KVORepresentable {
|
|
init?(KVOValue: KVOType?) {
|
|
guard let KVOValue = KVOValue else {
|
|
return nil
|
|
}
|
|
|
|
self.init(KVOValue: KVOValue)
|
|
}
|
|
}
|
|
|