Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rx extension for UIImagePickerController+Rx.swift
//
// 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