Skip to content

No ability to inject own scheduler #51

@ivanmkc

Description

@ivanmkc

I'm using RxTest to test my network services which makes use of a virtual time TestScheduler. However, in Single+ModelMapper, you have fixed schedulers which are incompatible with RxTest as they would have to be replaced by the TestScheduler for unit tests. Similar discussion is here: ReactiveX/RxSwift#1100

Fix would be to do dependency injection of schedulers, perhaps with a default value.

Problematic code here:

public func map<T: Mappable>(to type: T.Type, keyPath: String? = nil) -> Single<T> {
        return observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
            .flatMap { response -> Single<T> in
                return Single.just(try response.map(to: type, keyPath: keyPath))
            }
            .observeOn(MainScheduler.instance)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions