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:
parent
96ef70cc2f
commit
43c0b952ec
|
|
@ -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 { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue