File tree Expand file tree Collapse file tree 2 files changed +1
-35
lines changed Expand file tree Collapse file tree 2 files changed +1
-35
lines changed Original file line number Diff line number Diff line change @@ -919,7 +919,7 @@ func completeValue(
919919 }
920920 }
921921
922- return result. flatMap ( to : Any ? . self ) { result -> Future < Any ? > in
922+ return result. tryFlatMap { result throws -> Future < Any ? > in
923923 // If result value is null-ish (nil or .null) then return .null.
924924 guard let result = result, let r = unwrap ( result) else {
925925 return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
Original file line number Diff line number Diff line change @@ -17,16 +17,6 @@ public extension Collection {
1717 }
1818}
1919
20- extension Collection {
21- func flatMap< S, T> (
22- to _: T . Type ,
23- on eventLoopGroup: EventLoopGroup ,
24- _ callback: @escaping ( [ S ] ) throws -> Future < T >
25- ) -> Future < T > where Element == Future < S > {
26- return flatten ( on: eventLoopGroup) . flatMap ( to: T . self, callback)
27- }
28- }
29-
3020extension Dictionary where Value: FutureType {
3121 func flatten( on eventLoopGroup: EventLoopGroup ) -> Future < [ Key : Value . Expectation ] > {
3222 // create array of futures with (key,value) tuple
@@ -63,30 +53,6 @@ extension OrderedDictionary where Value: FutureType {
6353 }
6454}
6555
66- extension Future {
67- func flatMap< T> (
68- to _: T . Type = T . self,
69- _ callback: @escaping ( Expectation ) throws -> Future < T >
70- ) -> Future < T > {
71- let promise = eventLoop. makePromise ( of: T . self)
72-
73- whenSuccess { expectation in
74- do {
75- let mapped = try callback ( expectation)
76- mapped. cascade ( to: promise)
77- } catch {
78- promise. fail ( error)
79- }
80- }
81-
82- whenFailure { error in
83- promise. fail ( error)
84- }
85-
86- return promise. futureResult
87- }
88- }
89-
9056public protocol FutureType {
9157 associatedtype Expectation
9258 func whenSuccess( _ callback: @escaping @Sendable ( Expectation ) -> Void )
You can’t perform that action at this time.
0 commit comments