@@ -10,57 +10,47 @@ import RxSwift
1010import Moya
1111import ObjectMapper
1212
13-
1413/// Extension for processing Responses into Mappable objects through ObjectMapper
1514public extension PrimitiveSequence where TraitType == SingleTrait , ElementType == Response {
1615
1716 /// Maps data received from the signal into an object
1817 /// which implements the Mappable protocol and returns the result back
1918 /// If the conversion fails, the signal errors.
20- public func mapObject< T: BaseMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < T > {
21- return observeOn ( ConcurrentDispatchQueueScheduler ( qos: . background) )
22- . flatMap { response -> Single < T > in
19+ public func mapObject< T: BaseMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < T > {
20+ return flatMap { response -> Single < T > in
2321 return Single . just ( try response. mapObject ( type, context: context) )
2422 }
25- . observeOn ( MainScheduler . instance)
2623 }
2724
2825 /// Maps data received from the signal into an array of objects
2926 /// which implement the Mappable protocol and returns the result back
3027 /// If the conversion fails, the signal errors.
31- public func mapArray< T: BaseMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < [ T ] > {
32- return observeOn ( ConcurrentDispatchQueueScheduler ( qos: . background) )
33- . flatMap { response -> Single < [ T ] > in
28+ public func mapArray< T: BaseMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < [ T ] > {
29+ return flatMap { response -> Single < [ T ] > in
3430 return Single . just ( try response. mapArray ( type, context: context) )
3531 }
36- . observeOn ( MainScheduler . instance)
3732 }
3833}
3934
4035
4136// MARK: - ImmutableMappable
42-
4337public extension PrimitiveSequence where TraitType == SingleTrait , ElementType == Response {
4438
4539 /// Maps data received from the signal into an object
4640 /// which implements the ImmutableMappable protocol and returns the result back
4741 /// If the conversion fails, the signal errors.
48- public func mapObject< T: ImmutableMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < T > {
49- return observeOn ( ConcurrentDispatchQueueScheduler ( qos: . background) )
50- . flatMap { response -> Single < T > in
42+ public func mapObject< T: ImmutableMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < T > {
43+ return flatMap { response -> Single < T > in
5144 return Single . just ( try response. mapObject ( type, context: context) )
5245 }
53- . observeOn ( MainScheduler . instance)
5446 }
5547
5648 /// Maps data received from the signal into an array of objects
5749 /// which implement the ImmutableMappable protocol and returns the result back
5850 /// If the conversion fails, the signal errors.
59- public func mapArray< T: ImmutableMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < [ T ] > {
60- return observeOn ( ConcurrentDispatchQueueScheduler ( qos: . background) )
61- . flatMap { response -> Single < [ T ] > in
51+ public func mapArray< T: ImmutableMappable > ( _ type: T . Type , context: MapContext ? = nil ) -> Single < [ T ] > {
52+ return flatMap { response -> Single < [ T ] > in
6253 return Single . just ( try response. mapArray ( type, context: context) )
6354 }
64- . observeOn ( MainScheduler . instance)
6555 }
6656}
0 commit comments