From 43c0b952ec137287297e5159861c19a85fdd6e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Alves?= Date: Tue, 16 Aug 2016 10:47:26 +0200 Subject: [PATCH] Remove `AnyObject` constraint and add a new protocol `ReactiveCompatible` to mark types which should be extended with the `rx` var. --- RxCocoa/Common/Reactive.swift | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/RxCocoa/Common/Reactive.swift b/RxCocoa/Common/Reactive.swift index b803379c..f6661fd2 100644 --- a/RxCocoa/Common/Reactive.swift +++ b/RxCocoa/Common/Reactive.swift @@ -22,7 +22,7 @@ */ -public struct Reactive { +public struct Reactive { public let base: Base public init(_ base: Base) { @@ -30,11 +30,18 @@ public struct Reactive { } } -/** - Extend NSObject with `rx` proxy. -*/ -public extension NSObjectProtocol { +public protocol ReactiveCompatible { + associatedtype CompatibleType + var rx: Reactive { get } +} + +public extension ReactiveCompatible { public var rx: Reactive { return Reactive(self) } } + +/** + Extend NSObject with `rx` proxy. +*/ +extension NSObject: ReactiveCompatible { }