@@ -9,54 +9,38 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
99
1010 /// Filters out responses that don't fall within the given range, generating errors when others are encountered.
1111 public func filter( statusCodes: ClosedRange < Int > ) -> Single < ElementType > {
12- return flatMap { response -> Single < ElementType > in
13- return Single . just ( try response. filter ( statusCodes: statusCodes) )
14- }
12+ return flatMap { . just( try $0. filter ( statusCodes: statusCodes) ) }
1513 }
1614
1715 public func filter( statusCode: Int ) -> Single < ElementType > {
18- return flatMap { response -> Single < ElementType > in
19- return Single . just ( try response. filter ( statusCode: statusCode) )
20- }
16+ return flatMap { . just( try $0. filter ( statusCode: statusCode) ) }
2117 }
2218
2319 public func filterSuccessfulStatusCodes( ) -> Single < ElementType > {
24- return flatMap { response -> Single < ElementType > in
25- return Single . just ( try response. filterSuccessfulStatusCodes ( ) )
26- }
20+ return flatMap { . just( try $0. filterSuccessfulStatusCodes ( ) ) }
2721 }
2822
2923 public func filterSuccessfulStatusAndRedirectCodes( ) -> Single < ElementType > {
30- return flatMap { response -> Single < ElementType > in
31- return Single . just ( try response. filterSuccessfulStatusAndRedirectCodes ( ) )
32- }
24+ return flatMap { . just( try $0. filterSuccessfulStatusAndRedirectCodes ( ) ) }
3325 }
3426
3527 /// Maps data received from the signal into an Image. If the conversion fails, the signal errors.
3628 public func mapImage( ) -> Single < Image ? > {
37- return flatMap { response -> Single < Image ? > in
38- return Single . just ( try response. mapImage ( ) )
39- }
29+ return flatMap { . just( try $0. mapImage ( ) ) }
4030 }
4131
4232 /// Maps data received from the signal into a JSON object. If the conversion fails, the signal errors.
4333 public func mapJSON( failsOnEmptyData: Bool = true ) -> Single < Any > {
44- return flatMap { response -> Single < Any > in
45- return Single . just ( try response. mapJSON ( failsOnEmptyData: failsOnEmptyData) )
46- }
34+ return flatMap { . just( try $0. mapJSON ( failsOnEmptyData: failsOnEmptyData) ) }
4735 }
4836
4937 /// Maps received data at key path into a String. If the conversion fails, the signal errors.
5038 public func mapString( atKeyPath keyPath: String ? = nil ) -> Single < String > {
51- return flatMap { response -> Single < String > in
52- return Single . just ( try response. mapString ( atKeyPath: keyPath) )
53- }
39+ return flatMap { . just( try $0. mapString ( atKeyPath: keyPath) ) }
5440 }
5541
5642 /// Maps received data at key path into a Decodable object. If the conversion fails, the signal errors.
5743 public func map< D: Decodable > ( _ type: D . Type , atKeyPath keyPath: String ? = nil , using decoder: JSONDecoder = JSONDecoder ( ) , failsOnEmptyData: Bool = true ) -> Single < D > {
58- return flatMap { response -> Single < D > in
59- return Single . just ( try response. map ( type, atKeyPath: keyPath, using: decoder, failsOnEmptyData: failsOnEmptyData) )
60- }
44+ return flatMap { . just( try $0. map ( type, atKeyPath: keyPath, using: decoder, failsOnEmptyData: failsOnEmptyData) ) }
6145 }
6246}
0 commit comments