         }
     }
 
+    /**
+     * `Result` equivalent of `Observable`'s `flatMap` only affecting `.failure` error.
+     * - NOTE: See **mapError** and [FlatMap operator](http://reactivex.io/documentation/operators/flatmap.html).
+     */
     public func flatMapError<O>(_ selector: @escaping (E.Error) -> O) -> Observable<Result<E.Value, O.E>> where O : ObservableConvertibleType {
         return asObservable().flatMap { result -> Observable<Result<E.Value, O.E>> in
             result.analysis(

import Result

extension ObservableConvertibleType where E: ResultProtocol {
    
    public func filterError() -> Observable<E.Value> {
        return asObservable().map { $0.value }.filterNil()
    }
    
    public func errorOnly() -> Observable<E.Error> {
        return asObservable().map { $0.error }.filterNil()
    }
    
    public func mapValue<T>(_ transform: @escaping (E.Value) -> T) -> Observable<Result<T, E.Error>> {
        return asObservable().map { $0.map(transform) }
    }
    
    public func mapError<T: Error>(_ transform: @escaping (E.Error) -> T) -> Observable<Result<E.Value, T>> {
        return asObservable().map { $0.mapError(transform) }
    }

    public func flatMapValue<O>(_ selector: @escaping (E.Value) -> O) -> Observable<Result<O.E, E.Error>> where O : ObservableConvertibleType {
        return asObservable().flatMap { result -> Observable<Result<O.E, E.Error>> in
            result.analysis(

        }
    }

    /**
     * Convenience method equivalent to `Observable.rewrite(with:)`. Rewrites `.success` value with value passed to the method.
     */
    public func rewriteValue<T>(newValue: T) -> Observable<Result<T, E.Error>> {
        return mapValue { _ in newValue }
    }

    /**
     * If the `.success` value is `nil`, replace it with the value provided.
     * - parameter value: value to be used if `.success` value is `nil`
     */
    public func recover(_ value: E.Value) -> Observable<E.Value> {
        return asObservable().map { $0.value ?? value }
    }

    /**
     * Unwrap the value in `.success`, if it's `.failure`, `nil` will be sent instead.
     */
    public func recoverWithNil() -> Observable<Self.E.Value?> {
        return asObservable().map { $0.value }
    }
