The docs state:
If you return any object from continueWith function - this will become a result of the new function. And if you want to call into more tasks and return those results - you can use continueWithTask. This gives you an ability to chain more asynchronous work together.
For me the difference is absolutely not clear, especially since both have exactly the same signature in Swift.
@discardableResult
public func continueWith<S>(_ executor: Executor = .default, continuation: @escaping ((Task) throws -> S)) -> Task<S> {
vs
@discardableResult
public func continueWithTask<S>(_ executor: Executor = .default, continuation: @escaping ((Task) throws -> Task<S>)) -> Task<S> {
in the source code for continueWith it states
- returns: A task that will be completed with a result from a given closure.
continueWithTask has
- returns: A task that will be completed when a task returned from a closure is completed.
Does this mean that the task returned by continueWith will have a completion/error state as soon as it is returned, while in continueWithTask it might not immediately be the case?
And in the second case, is the task that will be completed not simply the task returned by the closure?
The docs state:
If you return any object from
continueWithfunction - this will become a result of the new function. And if you want to call into more tasks and return those results - you can usecontinueWithTask. This gives you an ability to chain more asynchronous work together.For me the difference is absolutely not clear, especially since both have exactly the same signature in Swift.
vs
in the source code for
continueWithit statescontinueWithTaskhasDoes this mean that the task returned by
continueWithwill have a completion/error state as soon as it is returned, while incontinueWithTaskit might not immediately be the case?And in the second case, is the
task that will be completednot simply the task returned by the closure?