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.