From 2e6cfdc15c1379bf97d39d5e36778e75d0f9691f Mon Sep 17 00:00:00 2001 From: Yury Korolev Date: Tue, 3 May 2016 12:01:23 +0300 Subject: [PATCH] Docs for Reactive protocol --- RxCocoa/Common/Reactive.swift | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/RxCocoa/Common/Reactive.swift b/RxCocoa/Common/Reactive.swift index 56bc5846..5a84ca97 100644 --- a/RxCocoa/Common/Reactive.swift +++ b/RxCocoa/Common/Reactive.swift @@ -6,6 +6,28 @@ // Copyright © 2016 Krunoslav Zaher. All rights reserved. // +/** +We can use `Reactive` protocol as customization point for constrained protocol extensions. + +General pattern would be: + +```swift +// 1. Conform SomeType to Reactive protocol +extension SomeType: Reactive {} + +// 2. Extend Reactive protocol with constrain on Self +// Read as: Reactive Extension where Self is a SomeType +extension Reactive where Self: SomeType { + // 3. Put any specific reactive extension for SomeType here +} +``` + +With this approach we can have more specialized methods and properties using +`Self` and not just specialized on common base type. + +See UIGestureRecognizer+Rx.swift as an example +*/ + public protocol Reactive { }