Created
December 27, 2016 08:50
-
-
Save hungdv136/d85964cb9dcda4c930636d5bbd0da822 to your computer and use it in GitHub Desktop.
Rx extension for UIImagePickerController+Rx.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIImagePickerController+Rx.swift | |
// RxSubject | |
// | |
// Created by Hung Dinh Van on 12/27/16. | |
// Copyright © 2016 ChuCuoi. All rights reserved. | |
// | |
import UIKit | |
import RxCocoa | |
import RxSwift | |
extension UIImagePickerController { | |
/// Factory method that enables subclasses to implement their own `delegate`. | |
/// - returns: Instance of delegate proxy that wraps `delegate`. | |
func createRxDelegateProxy() -> RxImagePickerControllerDelegateProxy { | |
return RxImagePickerControllerDelegateProxy(parentObject: self) | |
} | |
} | |
extension Reactive where Base: UIImagePickerController { | |
/// Reactive wrapper for `delegate`. | |
/// | |
/// For more information take a look at `DelegateProxyType` protocol documentation. | |
var delegate: DelegateProxy { | |
return RxImagePickerControllerDelegateProxy.proxyForObject(base) | |
} | |
/// Reactive wrapper for `didFinishPickingMediaWithInfo`. | |
var didFinishPickingMediaWithInfo: Observable<[String : Any]> { | |
let proxy = RxImagePickerControllerDelegateProxy.proxyForObject(base) | |
return proxy.didFinishPickingSubject | |
} | |
/// Reactive wrapper for `didCancel`. | |
var didCancel: Observable<Void> { | |
let proxy = RxImagePickerControllerDelegateProxy.proxyForObject(base) | |
return proxy.didCancelPickingSubject | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment