-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method to EventLoop
that is to EventLoop.submit
as Future.then
is to Future.map
.
#426
Labels
Comments
Lukasa
added
kind/enhancement
Improvements to existing feature.
help wanted
good first issue
Good for newcomers
labels
May 22, 2018
Whoever does this should also clean up the workarounds from #424. |
Any name suggestions for the new function? |
@karim-elngr really sorry for the huge delay, this just slipped through. We just talked about it and |
Lukasa
pushed a commit
that referenced
this issue
Oct 22, 2019
Motivation: Calling EventLoop's submit method with a task that returns an EventLoopFuture results in a double future. flatSubmit provides an alternative which does not return a double future. Modifications: Added flatSubmit() to the EventLoop protocol and provided a default implementation that returns the result of calling flatMap { $0 } on the EventLoopFuture returned from task. Result: Additive change only. flatSubmit method on EventLoop will be available for use.
fixed in #1174 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Currently
EventLoop.submit
is defined like this:func submit<T>(_ task: @escaping () throws -> T) -> EventLoopFuture<T>
.The problem here is that
T
may beEventLoopFuture<U>
. In this instance, you end up withEventLoopFuture<EventLoopFuture<U>>
as the return type ofsubmit
, and double futures are annoying to work with.It would be very helpful to have a method that can deal with this. To add this in a backward-compatible way, we could add the method to the
EventLoop
protocol, and also provide an extension with a default implementation that just does.then { $0 }
on the returned double-future from the default method.The text was updated successfully, but these errors were encountered: