File tree 2 files changed +1
-35
lines changed
2 files changed +1
-35
lines changed Original file line number Diff line number Diff line change @@ -919,7 +919,7 @@ func completeValue(
919
919
}
920
920
}
921
921
922
- return result. flatMap ( to : Any ? . self ) { result -> Future < Any ? > in
922
+ return result. tryFlatMap { result throws -> Future < Any ? > in
923
923
// If result value is null-ish (nil or .null) then return .null.
924
924
guard let result = result, let r = unwrap ( result) else {
925
925
return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
Original file line number Diff line number Diff line change @@ -17,16 +17,6 @@ public extension Collection {
17
17
}
18
18
}
19
19
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
-
30
20
extension Dictionary where Value: FutureType {
31
21
func flatten( on eventLoopGroup: EventLoopGroup ) -> Future < [ Key : Value . Expectation ] > {
32
22
// create array of futures with (key,value) tuple
@@ -63,30 +53,6 @@ extension OrderedDictionary where Value: FutureType {
63
53
}
64
54
}
65
55
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
-
90
56
public protocol FutureType {
91
57
associatedtype Expectation
92
58
func whenSuccess( _ callback: @escaping @Sendable ( Expectation ) -> Void )
You can’t perform that action at this time.
0 commit comments