Remove `AnyObject` constraint and add a new protocol `ReactiveCompatible` to mark types which should be extended with the `rx` var.

This commit is contained in:
Jérôme Alves 2016-08-16 10:47:26 +02:00
parent 96ef70cc2f
commit 43c0b952ec
1 changed files with 12 additions and 5 deletions

View File

@ -22,7 +22,7 @@
*/
public struct Reactive<Base: AnyObject> {
public struct Reactive<Base> {
public let base: Base
public init(_ base: Base) {
@ -30,11 +30,18 @@ public struct Reactive<Base: AnyObject> {
}
}
/**
Extend NSObject with `rx` proxy.
*/
public extension NSObjectProtocol {
public protocol ReactiveCompatible {
associatedtype CompatibleType
var rx: Reactive<CompatibleType> { get }
}
public extension ReactiveCompatible {
public var rx: Reactive<Self> {
return Reactive(self)
}
}
/**
Extend NSObject with `rx` proxy.
*/
extension NSObject: ReactiveCompatible { }