From 1570dc70c5c4a6a8f9d22aba04312d5ac3e736bd Mon Sep 17 00:00:00 2001 From: tarunon Date: Sat, 26 Mar 2016 00:26:24 +0900 Subject: [PATCH] adding drive to variable operator to Driver --- .../CocoaUnits/Driver/Driver+Subscription.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift b/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift index 17bbb332..d56f8cb3 100644 --- a/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift +++ b/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift @@ -26,6 +26,19 @@ extension DriverConvertibleType { return self.asObservable().subscribe(observer) } + /** + Creates new subscription and sends elements to variable. + + - parameter variable: Target variable for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer from the variable. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + public func drive(variable: Variable) -> Disposable { + return drive(onNext: { e in + variable.value = e + }) + } + /** Subscribes to observable sequence using custom binder function.