Repository: ReactiveX/RxSwift
File: RxCocoa/Traits/SharedSequence/ObservableConvertibleType+SharedSequence.swift (Swift)

Code before:
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorJustReturn: E) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchErrorJustReturn(onErrorJustReturn)
        return SharedSequence(source)
    }
    
    /**
    Converts anything convertible to `Observable` to `SharedSequence` unit.
    
    - parameter onErrorDriveWith: SharedSequence that provides elements of the sequence in case of error.
    - returns: Driving observable sequence.
    */
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchError { _ in
                onErrorDriveWith.asObservable()
            }
        return SharedSequence(source)
    }

    /**
    Converts anything convertible to `Observable` to `SharedSequence` unit.
    
    - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error.
    - returns: Driving observable sequence.
    */
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorRecover: @escaping (_ error: Swift.Error) -> SharedSequence<S, E>) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchError { error in
                onErrorRecover(error).asObservable()
            }
        return SharedSequence(source)
    }
}


Review comment (suggestion):
```
/Users/alan/repositories/github/RxSwift/RxCocoa/Traits/SharedSequence/ObservableConvertibleType+SharedSequence.swift:34:37: warning: redundant conformance constraint 'S': 'SharingStrategyProtocol'
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
                                    ^
/Users/alan/repositories/github/RxSwift/RxCocoa/Traits/SharedSequence/ObservableConvertibleType+SharedSequence.swift:34:114: note: conformance constraint 'S': 'SharingStrategyProtocol' inferred from type here
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
                                                                                                                 ^
```

Code after:
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorJustReturn: E) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchErrorJustReturn(onErrorJustReturn)
        return SharedSequence(source)
    }
    
    /**
    Converts anything convertible to `Observable` to `SharedSequence` unit.
    
    - parameter onErrorDriveWith: SharedSequence that provides elements of the sequence in case of error.
    - returns: Driving observable sequence.
    */
    #if swift(>=3.2)
    public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchError { _ in
                onErrorDriveWith.asObservable()
        }
        return SharedSequence(source)
    }
    #else
    public func asSharedSequence<S: SharingStrategyProtocol>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchError { _ in
                onErrorDriveWith.asObservable()
            }
        return SharedSequence(source)
    }
    #endif

    /**
    Converts anything convertible to `Observable` to `SharedSequence` unit.
    
    - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error.
    - returns: Driving observable sequence.
    */
    #if swift(>=3.2)
    public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorRecover: @escaping (_ error: Swift.Error) -> SharedSequence<S, E>) -> SharedSequence<S, E> {
        let source = self
            .asObservable()
            .observeOn(S.scheduler)
            .catchError { error in
                onErrorRecover(error).asObservable()
        }
        return SharedSequence(source)